while True:
# main program
number = (" ")
total = 0
num1 = int(input("enter a number"))
total = total + num1
num2 = int(input("enter a number"))
total = total + num2
num3 = int(input("enter a number"))
total = total + num3
if total > 100:
print("That's a big number!")
else:
print("That's a small number.")
print(total)
while True:
answer = raw_input("Run again? (y/n): ")
if answer in y, n:
break
print("Invalid input.")
if answer == 'y':
continue
else:
print 'Goodbye'
break
基本上我想程序在用戶輸入'y'作爲'run again?'的響應時重新啓動?任何幫助將被廣泛讚賞。謝謝。如果用戶輸入'重新運行?'重新啓動Python程序?是'y'
試着寫你的主要的功能(https://docs.python.org/2/library/__main__.html)然後調用的main()'如果答案=='y'' – burhan