I'm just starting to learn how to code with Python 3.x and I'm trying to make a number game where the user tries to guess a random integer between 1-100. The program is supposed to give the user a hint by telling them if their guess was too high or too low, but how do I let the program give an output and take another guess after that?
Here's the code so far: (line breaks may look a little messy)
from random import *
x = randint(1, 100) # Pick a random number between 1 and 100.
print("I'm thinking of a number between 1 and 100.") #informs user
guess = input("Guess which number I'm thinking of: ") #takes guess for evaluation
print("Your first guess was "+guess)
if x > int(guess):
print("The number I'm thinking of is higher than "+guess)
if x < int(guess):
print("The number I'm thinking of is lower than "+guess)
if x == int(guess):
print("Correct!")
print("End") #annouces end of program
Aucun commentaire:
Enregistrer un commentaire