I am making a guessing game, and I want the option to input how many tries you have. The number that you put will be the amount of times you will have to guess the random number. Problem is, I do not know how to put this in the game. How do I implement this? I have tried for loops, but it seems to not reach it no matter where I put it. Nothing seems to work, and I don't want to end up breaking my code. Help!
from random import randint
from time import sleep as wait
while True:
while True:
try:
# Player chooses what the random numbers will be in between.
range_ = int(input("Enter the range that your numbers are going to be between. (ex. 50): "))
# Cannot put a 0, a 1, or a negative number.
if range_ == 0:
print("\nundefined cannot <0>\n")
continue
if range_ == 1:
print("\nundefined, cannot add 1 to the range.\n")
continue
if range_ < 0:
print("\nNo negatives!\n")
continue
# Player chooses how many tries they want.
tries = int(input("Enter the amount of tries you want: "))
# Cannot put a 0 or a negative number.
if tries == 0:
print("\nundefined, cannot <0> @ tries::int 0\n")
continue
if tries < 0:
print("\nWhy would you want less than 0 tries?\n")
continue
break
except ValueError:
print("\nEnter a whole number please!\n")
continue
ai = randint(1, range_ + 1)
while True:
player = int(input("Enter number: "))
if player > range_:
print("Please put a number inside of the range.")
continue
if player < ai:
print("\nBigger!\n")
continue
if player > ai:
print("\nSmaller!\n")
continue
if player == ai:
print("You win!\n")
continue
if player != int:
print("Put a whole number!")
continue
if player == 0:
print("\n\nno\n\n")
wait(5)
break
if player == "":
continue
again = str(input("Do you want to play again? (yes/no): ")).lower()
if again != "yes":
print("Goodbye!")
wait(3)
break
else:
continue