一切正常,除非用户键入N以结束while循环,它不会转到For语句(运行程序时会发生这种情况,在shell和py中工作正常)。 / p>
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))
答案 0 :(得分:0)
#!/usr/bin/python
my_list=[]
val=int
sum1=int
n=int(input('Enter the limit:'))
for i in range(0,n):
val=int(input('number:'))
my_list.append(val)
sum1=sum(my_list)
print sum1
res=float(sum1/n)
print 'The average is:',res
答案 1 :(得分:-3)
在我将输入更改为raw_input之前,它一直在破坏。现在它在输入不是Y时退出while循环:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>