I'm writing a program that, via a while loop, takes user-entered data and adds each value to a list (they're temperatures) until the user enters 'q' (quit). I need to find the minimum and maximum value of the list. Here is my code so far:
temps = []
daily = 1
daily = float(daily)
while daily != "q":
daily = (raw_input("Today's Temperature: "))
if str.isdigit(daily) and daily>0:
temps.append(daily)
elif daily<0:
print "Positive temperatures only please."
else:
print "Calculating statistics..."
temps = sorted(temps)
print map(float, temps)
maximum = (max(temps))
print "Maximum:",maximum
When I run this and enter values (90, 80, 70, 60, 50, q) it works fine and gives me 90 as the maximum and 50 as the minimum.
However, when I run this and enter values (30, 28, 1, 9, 26, 14, q) it returns 9 as the maximum and 1 as the minimum.
Basically, it treats 9.0 as greater than any number that starts with 8 or less. (i.e. 88, 56, 30, etc.)
How do I fix that?