除了当用户键入N结束while循环时,一切都在工作,它不会进入For语句(当您运行该程序时发生这种情况,在shell中工作正常并且在py中)。查找列表中的n个数字的平均值
potato = []
count = 0
avg = 0
question = input('Finding averages, continue? Y or N: ')
while question == 'Y' and count <= 12:
num = int(input('Enter a number: '))
potato.append(num)
count += 1
question = input('Continue? Y or N: ')
for fries in potato:
avg = sum(potato)/count
print(fries,fries-avg)
print('average is: ' + str(avg))
你得到错误信息?显示它的问题。 – furas
无限循环?不是“休息”? – estebanpdl
这对我来说很好,也许这是一个蟒蛇2 - > 3的问题? – shuttle87