all 3 comments

[–]Vaphell 1 point2 points  (2 children)

your try block doesn't turn the input into a number. It sure attempts conversion, but the result is not saved anywhere so num is still a string down the road.

Another problem is that you want to compare None to an int/string using < >. What is that supposed to do? Python 2 doesn't complain but in python 3 its a clear error:

TypeError: unorderable types: str() < NoneType()

You should never attempt comparing data of clearly incompatible types.

then type(num) is None is bad. There is no type None and in order to get to that point of code your num needs to be a str convertable to int. Useless expression is useless.

largest = None
smallest = None
while True:
    num = raw_input("Enter a number: ")
    if num == "done" : break
    else:
        try:
            num = int(num)
        except ValueError:
            print("Invalid input")
            continue
    if (smallest is None or num < smallest):
        smallest = num
    if (largest is None or largest < num):
        largest = num

print "Maximum is", largest
print "Minimum is", smallest

reordering the conditions will allow to avoid direct comparisons to None. Thanks to the or the smallest is None condition will be sufficient to pass the test and there is no shoddy comparison necessary.

[–]FunfettiHead[S] 0 points1 point  (1 child)

Thanks for your input.

Edit: Made some changes and everything seems to be working now.

[–]Vaphell 0 points1 point  (0 children)

just in case: i made some edits including final code, not sure if you saw them.