【发布时间】:2016-09-30 17:10:34
【问题描述】:
我遇到了麻烦,因为我要求用户将 6 个数字输入到一个列表中,然后根据用户的输入对其进行总计和平均。这是我的HWK。请帮忙。
x = 0
list = []
while x < 6:
user = int(input("Enter a number"))
list.append(user)
x = x + 1
numb = input("Do you want a total or average of numbers?")
numb1 = numb.lower
if numb1 == "total":
【问题讨论】:
-
sum(list),但请不要将您的列表命名为list,因为这是一个内置类型。 -
不是说你有minimal reproducible example,但我敢打赌
numb1 = numb.lower不会像你想的那样做。