Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
Forked from anonymous/gist:74c9837eaef5fd4777db31cf7d412767
Last active April 14, 2016 07:46
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 tangentstorm/d7ceb95bda0ad95c74033330b83ddbf6 to your computer and use it in GitHub Desktop.
Save tangentstorm/d7ceb95bda0ad95c74033330b83ddbf6 to your computer and use it in GitHub Desktop.
def read_ints():
i = 0
while True:
s = input('enter number[%i]:' % i)
try:
yield int(s); i+=1
except ValueError:
if s == "": return
else: print "ignoring invalid number"
print(sum(read_ints()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment