Skip to content

Instantly share code, notes, and snippets.

@spaghettiSyntax
Created December 6, 2017 08:26
Show Gist options
  • Save spaghettiSyntax/498e4dc7b35f869f7ed0c91ada209773 to your computer and use it in GitHub Desktop.
Save spaghettiSyntax/498e4dc7b35f869f7ed0c91ada209773 to your computer and use it in GitHub Desktop.
Tony Gaddis Python: Sentinel
# 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