I wrote the code below for getting max and min values as part of my MOOC assignment. This program continuously takes input from the user until the user types 'done'.
Once 'done' is typed, the program gives the results for max and min values. The problem is that the result for max value is always correct, but the result for min value is always "None".
largest = None
smallest = None
while ( True ) :
inp = raw_input('Enter a number: ')
if inp == 'done' :
break
try:
inp = float(inp)
except:
print 'Invalid input'
continue
if inp is None or inp > largest:
largest = inp
if inp is None or inp < smallest:
smallest = inp
print largest, smallest