Advertisement
Guest User

Untitled

a guest
Oct 8th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # The following code contains two semantic errors. Correct it so that it reads in integers until the user enters -1, and then prints the sum of the integers (8 points)
  2.  
  3. def getLines():
  4.     inputs = []
  5.     while True:
  6.         line = raw_input('Enter a positive integer, -1 to quit: ')
  7.         if line == -1:
  8.             break
  9.         inputs.append(line)
  10. total = 0
  11. for e in getLines():
  12.     total += e
  13. print total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement