Skip to content

Instantly share code, notes, and snippets.

@yosefsadek
Created January 17, 2020 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosefsadek/79b9f3dc4d0c53b191388e74ac244694 to your computer and use it in GitHub Desktop.
Save yosefsadek/79b9f3dc4d0c53b191388e74ac244694 to your computer and use it in GitHub Desktop.
py
total = 0
another = "Y"
#the loop will repeat while the user types Y when asked if they want to enter another number
while another == "Y":
#asks the user to enter a number
number = int(input("Enter a number to add to the total: "))
#adds the number entered to the total
total = total + number
#asks the user if they want to enter another number
another = input("Do you want to enter another number? Y/N ")
#after the loop ends it outputs the total
print("The total of your numbers was" + str(total))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment