Home > Net >  Resetting counter? What have I done wrong? *beginner*
Resetting counter? What have I done wrong? *beginner*

Time:09-29

Apparently, when this program asks for another number it adds all the numbers in the input together until the end of the program. How would I go about resetting the counter for this program? Where did I go wrong? here's my code in replit

CodePudding user response:

if again != 'y' :

sum = 0.0

break

CodePudding user response:

if you want the sum to reset when the user inputs 'y', you have to initalize sum = 0 in the while loop.

CodePudding user response:

change line 9, so you won't reuse the previous sum value

sum = number_one   number_two
  • Related