试图显示数组中有多少值高于计算的平均值的计数,当我出于某种原因运行我的代码时,它会跳过计数器循环以计算高于平均值的学生年龄:我加载了具有 3 个年龄值的数组35,25 和 50 并且想要显示有多少高于平均值但它跳过了这个?请协助,另外,如果我想退出循环并且不在 if/else 中的 else 上放置任何东西,如果你想在 else 上留出空白空间,你能放什么,所以没有任何改变?到目前为止,这是我的代码:
st_age = [0] * 3
for g in range(0,3):
st_age[g] = int(input("Enter student age "))
g = 0
sum = 0
count = 1
count2 = 0
while g < len(st_age):
sum = sum + st_age[g]
g += 1
average = sum / len(st_age) #the average calc.
print "the average is:", average
#starting counter loop here:
g = 0
while g < len(st_age):
if st_age[g] > average:
count = count + 1
else: count = count + 1 # I don't know what to put here, it skips the whole thing
print "the number above the average is:", count