小编Chr*_*ris的帖子

循环列表?

我有一个数字列表,我想要这样,在输入3个数字之后,它们将总结,除非其中一个数字是13,否则其余数字将无效并且不能总结.

因此,如果列表是[1, 13, 2]最终总和将是1.

total = 0
def lucky_sum():
    total = 0
    lucky_sum = []
    a = input("Input a number")
    b = input("Input a number")
    c = input("Input a number")
    lucky_sum.append(a)
    lucky_sum.append(b)
    lucky_sum.append(c)


while **What do I place here??** != 13:
    total += **and here**
    if i== 13:
        break
print total

lucky_sum()
Run Code Online (Sandbox Code Playgroud)

python list while-loop pyscripter

1
推荐指数
1
解决办法
751
查看次数

标签 统计

list ×1

pyscripter ×1

python ×1

while-loop ×1