67.9k views
4 votes
What am I doing wrong?

What am I doing wrong?-example-1
User SJousse
by
5.2k points

1 Answer

4 votes

In your example, you're asking the user for a number and then you're setting total and nums equal to zero. This results in your first number being ignored by the program. I included the complete working code below:

num = int(input("Enter a number: "))

total = num

nums = 1

while (total <= 100):

num = int(input("Enter a number: "))

nums = nums + 1

total = total + num

print("Sum: "+str(total))

print("Numbers Entered: "+str(nums))

I hope this helps!

User Thao
by
4.3k points