I just can't figure out whats wrong with my little game. It gives always same answer printing "That's too high, pick lower." I have no idea what I did wrong.
import random
global number
number = random.randint(1,20)
def start():
name = raw_input("Welcome, what's your name?")
print "Hello %s guess the number from 1 to 20!" % (name)
game()
def game():
print "Guess a number!"
guess = int(raw_input(">"))
if (guess > number):
print "That's too high, pick lower."
game()
if (guess < number):
print "That's too low, pick higher."
game()
if (guess == number):
print "Yay that's the right one!"
start()
Aucun commentaire:
Enregistrer un commentaire