问题
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?
This is my code so far
count = 1
while count < 5:
count += 1
int(input("Enter a value: "))
回答1:
count = 1
total = 0
while count < 5:
count += 1
total += int(input("Enter a value: "))
print (total)
来源:https://stackoverflow.com/questions/40026355/python-adding-values-in-a-while-loop