私は状態が割り当てられています...このpythonスクリプトをループする方法は?
ユーザに2つの数字の入力を求める条件ループを作成します。数字を追加し、合計を表示する必要があります。ループはまた、ユーザに、操作を再度実行したいかどうかを尋ねるべきである。そうであれば、ループを繰り返す必要があります。そうでなければ、ループは終了します。
これがします私はあなたがこれを実行すると、プログラムの最初の部分が動作します
n1=input('Please enter your first number: ')
print "You have entered the number ",n1,""
n2=input('Pleae enter your second number: ')
print "You have entered the number ",n2,""
total=n1+n2
print "I will now add your numbers together."
print "The result is:",total
y = raw_input('Would you like to run the program again? y=yes n=no')
print'The program will now terminate.'
y='y'
while y=='y':
print 'The program will start over.'
...が出ているが、それを再度実行するかを尋ねたときに、それが継続的に「プログラムの状態になるものです始める。
ユーザーはプログラムを開始したいかどうかを入力することができますが、これをループするようにどのように言いますか?
ループコード全体を教えてください。 – shenshei
この例を見てください:http://wiki.python.org/moin/WhileLoop – ezdazuzena