I am making my way through the Python Codex Academy course and trying to build small side projects to help strengthen the lessons.
I am currently working on several games. I want the program to select a random number from 1 to 10 and the user to enter a guess.
Then the program will return a message that you won, or an invitation to choose another higher / lower number.
My code is below. I can not get him to repeat the process with the second user input.
I do not need an answer, just a hint.
import random
random.seed()
print "Play the Number Game!"
x = raw_input("Enter a whole number between 1 and 10:")
y = random.randrange(1, 10, 1)
if x == y:
print "You win."
print "Your number was ", x, " and my number was ", y
elif x > y:
x = raw_input("Your number was too high, pick a lower one: ")
elif x < y:
x = raw_input("Your number was too low, pick a higher one: ")
source
share