I'm attempting to create a simple "number guessing game" in Python.
My code:
minimum = 1
maximum = 100
current_number = 50
def new_number(x):
global sign, current_number, minimum, maximum
if x == ">":
minimum = current_number + 1
curent_number = minimum + maximum / 2
guess()
else:
maximum = current_number - 1
current_number = minimum + maximum / 2
guess()
print "Pick a number between 1 - 100, keep it in your head"
print "I'm going to guess it within 6 guesses"
def guess():
print "Is your number > or < %d" % current_number
guess()
sign = raw_input(": ")
new_number(sign)
Attempting to run it with the number "27" seems to work fine for the first iteration. However, after an input is placed on the second iteration, where the input == ">", I receive:
bash: syntax error near unexpected token `newline'
There's no specific line number that the error is pointing to. I am certain it has to do with the if x == ">":
section.