Advertisement
here2share

# largest_and_smallest.py

Jan 29th, 2016
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # largest_and_smallest.py
  2.  
  3. largest = 0
  4. smallest = 0
  5. while True:
  6.     num = raw_input("Enter a number: ")
  7.     if num == "done" : break
  8.    
  9.     while True:
  10.         try: # isolate expected catching, helps find other areas to debug
  11.             num = int(num) # instead of... num = num(type)
  12.         except:
  13.             print "Invalid entry"
  14.             break
  15.         if num >= largest : largest = num
  16.         if num <= smallest : smallest = num
  17.        
  18.         print "Maximum is", largest
  19.         print "Minimum is", smallest
  20.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement