I am trying to make a random number guesser game, and if the user gets it, I ask them if they want to play again. Problem is, if they say yes, the random number will be the same as it was last time. I am new to python and would really apprectate it if you could help me. Also, if there is anything I can inprove on, please tell me!
This is my code:
while True:
i = 1
import random
number = random.randint(1, 1000)
while 1 != 0:
player_guess = input("Choose a number from 1-1000 ")
if int(player_guess) == number:
print("You got it!")
i-1
x = input("do you want to play again? (y/n) ")
if x == "y":
import random
continue
if x == "n":
exit()
elif int(player_guess) >= number:
print("Too high!")
elif int(player_guess) <= number:
print("Too low!")
New contributor
Charles Fisher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.