我的家庭作业有问题。我需要创建一个 for 循环来计算某个值在列表中出现的次数。这是代码:
def get_test_scores():
tests = []
for i in range(SIZE):
test_score = int(input("Enter test score #"+str(i+1)+" in the range 0-100: "))
while (test_score <0) or (test_score >100):
print("ERROR!")
test_score = int(input("Enter test score #"+str(i+1)+" in the range 0-100: "))
tests.append(test_score)
return tests
def find_perfect(tests):
count = 0
for test_score in tests:
if test_score == 100:
count += 1
return count
我无法获得计数值来反映我输入了多少个 100
蛊毒传说
紫衣仙女
DIEA
相关分类