如何使用“您想再次运行此问题”循环此代码吗?
count = 1
total = 0
markslist = list()
while count <= 10:
newmark = input("Input Mark Out Of 100 (" + str(count) + ") ")
markslist.append(newmark)
if newmark > 100:
import sys
sys.exit("Error Mark is greater than 100 re-run program")
total = total + newmark
count = count + 1
average = (total / 10)
print "Average Mark = " + str(average)
答案 0 :(得分:4)
将整个代码包装在类似于此的循环中:
while True:
again = input('Go? (y/n): ')
if again != 'y':
break
# The entirety of the rest of your program would go here.