- Joined
- Mar 9, 2022
- Messages
- 1
- Reaction score
- 0
im trying to make a game where you guess a number under a certain amount of guesses, i tried putting in a command to make the game reapet however it just doesnt seem to work i need help with this, here is the code:
import random
rand = random.randint(1, 100)
guess_count = 0
guess_limit = 10
play = True
print(rand)
while play == True:
while guess_count < guess_limit:
guess_count += 1
answer = int(input("please enter a number between 1-100: "))
if answer == rand:
print("you got it in", guess_count, "guess(es)")
break
elif answer > rand:
print("lower than that!: ")
elif answer < rand:
print("higher than that!: ")
play = input("would you like to play again? (Y/N): ")
if play == ("y"):
play = True
elif play == ("n"):
play = False
import random
rand = random.randint(1, 100)
guess_count = 0
guess_limit = 10
play = True
print(rand)
while play == True:
while guess_count < guess_limit:
guess_count += 1
answer = int(input("please enter a number between 1-100: "))
if answer == rand:
print("you got it in", guess_count, "guess(es)")
break
elif answer > rand:
print("lower than that!: ")
elif answer < rand:
print("higher than that!: ")
play = input("would you like to play again? (Y/N): ")
if play == ("y"):
play = True
elif play == ("n"):
play = False