1print "Enter numbers, stops when negative value is entered:"
2nums = []
3while True: # infinite loop
4 try: n = int(raw_input("Enter a number: ")) # raw_input returns a string, so convert to an integer
5 except ValueError:
6 n = -1
7 print "Not a number!"
8 if n < 0: break # when n is negative, break out of the loop
9 else: nums.append(n)
10print "Maximum number: {}".format(max(nums))