The following is my code that calculates <, > incorrectly. About 3X into giving raw_input it will do things like value 12 < 4. I have added several float commands to try to keep it from having problems with string and int. I'm very new to coding.
largest = None smallest = None while True: num = raw_input("Enter a number: ") if num == "done" : break try: float(num) except ValueError: print "Invalid input" break float(num) if largest is None: largest = num float(largest) if smallest is None: smallest = num float(largest) if num > largest: largest = num float(largest) if num < smallest: smallest = num float(smallest) print num print "Maximum", largest print "Minimum", smallest
12 < 4; you're comparing"12" < "4"float(smallest)doesn't changesmallest. You need to dosmallest = float(smallest).try: num = float(num)then i dont think you will have to make any other changes. Just that you can remove all the float() calls.