First python program, syntax error in while loop

Neil Cerutti neilc at norwich.edu
Fri May 3 16:30:23 EDT 2013


On 2013-05-03, ryankoch38 at gmail.com <ryankoch38 at gmail.com> wrote:
> Thank you! It's 100% functional now, here's the final project:
>
> title = "Guess my number game:" 
> print title.title() 
> raw_input("Press any key to continue..") 
>
> import random 
>
> number = random.randrange(99) + 1 
> tries = 0 
> guess = int(raw_input("Guess my number! Secret - It is between 1 and 100 :")) 
>
> while (guess != number) and (tries <5): 
>     [...]
>         
> if (tries <5):
>     print "\nCongratulations! You guessed my number in", tries, "tries"
> else:
>     print "\nSorry, you took too many tries to guess my number!"
> raw_input("\n\n Press any key to exit..")
>
> ## Maybe now I can work on a useful project

Not quite yet. Players who guess correctly on the fifth try don't
get credit.

-- 
Neil Cerutti



More information about the Python-list mailing list