除了當用戶鍵入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