Python:在while循环中添加值 [英] Python: Adding values in a while loop
本文介绍了Python:在while循环中添加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 while 循环,我提示用户输入 5 个不同的数字并尝试创建这些数字的总数.我如何才能创造出这个总数?
Using a while loop, I'm prompting the user to enter 5 different numbers and trying to create a total of those numbers. How would I be able to create that total?
这是我目前的代码
count = 1
while count < 5:
count += 1
int(input("Enter a value: "))
推荐答案
count = 1
total = 0
while count < 5:
count += 1
total += int(input("Enter a value: "))
print (total)
这篇关于Python:在while循环中添加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文