[Tutor] Help with Max Number and Min number script

Bob Gailer bgailer at gmail.com
Sat Sep 17 17:15:18 EDT 2016


On Sep 17, 2016 4:55 PM, "Sharon Wallace" <swallace61 at embarqmail.com> wrote:
>
> Would you please help me with the last piece of this assignment?
>
>
>
> This is my code:
>
>
>
> largest = None
>
> smallest = None
>
>
>
> while True:
>
>                 num = raw_input("Enter a number:  ")
>
>                 if num == "done" : break
>
>                 print num
>
>
>
>                 try :
>
>                                 num = int(num)
>
>                 except :
>
>                                 print "Invalid input"
>
>                                 continue
>
>
>
>                 if num > largest :

> comparing integers To None is not a good idea. Your earlier program had
it right when you tested for None and greater than /  less then.

Another way to tackle this is to initialize largest to some extremely large
negative value and I smallest to some extremely large positive value.

When replying to these emails please always include the tutor group.

Congratulations on persisting and making it this far.

>                                 largest = num
>
>
>
>                 if num < smallest :
>
>                                 smallest = num
>
>
>
> print 'Maximum is', largest
>
> print 'Minimum is', smallest
.


More information about the Tutor mailing list