[Chicago] pedantic guessing game demo

Malcolm Newsome malcolm.newsome at gmail.com
Sun Mar 27 00:05:52 CET 2011


Thanks Brian. That's precisely what I needed!

Malcolm



On Sat, Mar 26, 2011 at 4:40 PM, Brian Ray <brianhray at gmail.com> wrote:

> Fun... One comment on:
>
> *    print "I'm thinking of a number between 1 - 100.  Can you guess what it is?"
>>
>>     random_num = random.randint(1, 100)
>>
>>     guess = int(input("Type a number between 1 - 100: "))
>>
>>
>>     error = guess < 1, guess < 100
>>
>> *
>>
>> I think that error was put in there so you can handle errors correct, one
> way to add some error handing there is add something like:
>
>     while True:
>
>         guess = int(input("Type a number between 1 - 100: "))
>         if guess < 1 or guess  > 100:
>             print "%s out of range try again" % guess
>             continue
>
>         break
>
>
>  - Brian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20110326/caea483f/attachment.html>


More information about the Chicago mailing list