[Tutor] What's the invalid syntax?

Nathan Pinno falcon3166 at hotmail.com
Thu Aug 24 00:19:25 CEST 2006


What's the invalid syntax in the following code?

# Hurkle Hunt
# This program is a game where you have to find a hurkle that the computer hides in a grid.
# Originally in Computer World pg. 70

import random

print "Hunt the Hurkle"
print
while 1:
    ans = raw_input("Do you want to play a game? Type Y to play, any other letter to quit.")
    while ans == "y" | ans == "Y":
        E = random.choice(range(9))
        N = random.choice(range(9))
        k = 1
        while k <= 5:
            print "Guess ", %d1.0, "."(k)
            X = int(raw_input("East Guess: "))
            Y = int(raw_input("North Guess: "))
            if X > E & Y == N:
                print "Go West"
                k = k + 1
            elif X > E & Y > N:
                print "Go SouthWest"
                k = k + 1
            elif X > E & Y < N:
                print "Go NorthWest"
                k = k + 1
            elif X == E & Y > N:
                print "Go South"
                k = k + 1
            elif X == E & Y < N:
                print "Go North"
                k = k + 1
            elif X < E & Y == N:
                print "Go East"
                k = k + 1
            elif X < E & Y > N:
                print "Go SouthEast"
                k = k + 1
            elif X < E & Y < N:
                print "Go NorthEast"
                k = k + 1
            else:
                print "Congrats! You found the hurkle in", %d1.0, " guesses!" (k)
                break
        else:
            print "You didn't find the hurkle in 5 tries! It was at: ", E, ",", N
            break
    else:
        break
    print "Goodbye!"
    break

Thanks!
Nathan Pinno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060823/05dc0395/attachment.html 


More information about the Tutor mailing list