Created
December 6, 2017 08:26
-
-
Save spaghettiSyntax/498e4dc7b35f869f7ed0c91ada209773 to your computer and use it in GitHub Desktop.
Tony Gaddis Python: Sentinel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Extra Credit sentinel loop to promp user for numbers. | |
# Any number less than zero, method should display all | |
# non-negative numbers typed. | |
total = 0 | |
print() | |
print('Now we will add up some integers\n' | |
'Input numbers, one at a time,\n' | |
'entering a negative integer to\n' | |
'stop the process.') | |
value = int(input('Input an integer: ')) | |
while value > -1: | |
total += value | |
value = int(input('Input an integer: ')) | |
print(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment