Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Weird Syntax Error

$
0
0
This code isn't working...
For some reason there's a syntax error where I've highlighted with comments
from random import randrange
print """This is going to be the hardest game ever.
You, the lowly player, have to think of a random whole number between 1 and 100.
I, the supreme computer, will guess the number at random."""
compGuess = randrange(100)+1
nowGuess = compGuess
tries = 1
def repeatFunc():
    global highLow
    highLow=raw_input("My guess was: "+str(compGuess)""". Is this too high or too low?
Or are you too scared to tell me the truth? Tell me either "high", "low" or "correct" exactly the way I have told you.""")
repeatFunc()
while highLow != "correct":
	if highLow == "high":
		while compGuess <= nowGuess : # the syntax error is at the nowGuess on this line
			compGuess=randrange(100)+1
		tries += 1
	elif highLow == "low":
		while compGuess >= nowGuess:
			compGuess = randrange(100)+1
		tries += 1
	repeatFunc()
print "Ha ha. I have beat you. Of course, it only took me", tries, "tries. Newbie."


Can you please tell me why there is a syntax error?
This is really annoying me.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>