lundi 22 mai 2017

Python error (please help)

The following is a snippet of code that is supposed to make a higher lower game. It is supposed to get a random number between two variables. But it doesn't go in between the 2 variables. Just try it and you will see.

from random import randint
high = 1000
low = 1
guess_num = 5
def me_guess(guess_num,high,low):
  print " "
  guess_num = randint(low,high)
  guess_num = str(guess_num)
  fact = raw_input(guess_num + " (higher or lower or yes) ")
  if fact == "higher":
    guess_num = low
    me_guess(guess_num,high,low)
  elif fact == "lower":
    guess_num = high
    me_guess(guess_num,high,low)
  elif fact == "yes":
    print "Yay! I got it."
    me_finish(guess_num)
  else:
    print "Error. Guessing again."
    me_guess(guess_num,high,low)
  me_guess(guess_num,high,low)




Aucun commentaire:

Enregistrer un commentaire