vendredi 17 novembre 2017

I need help making a random number generator as a lock in a simple game

Basically, I wanted to be able to make a code that would generate a random number and have the user try and guess that number by putting in an input. I thought it would work, but it just runs the else statement everytime even if I do guess the right number.

import random
def main():
  values = [1, 2, 3, 5, 7, 10]
  a = random.choice(values)
  print (a) ##########To see what the number is#########
  b = input('Enter a number: ')
  if b == a:
    print('You have guessed the number!')
  else:
    print('Try again')
    main()
main()




Aucun commentaire:

Enregistrer un commentaire