I hope you had something like this in mind. A guessing game that takes two inputs. Maximum integer and the users number choice and outputs if the user is correct or not. Game doesn't end because of the while-loop.
Working Code:
import random
while True:
try:
print("Welcome to GUESS THE NUMBER. Up to what number would you like to go to?")
maxNum = int(input())
if maxNum <= 1:
print('Number has to be greater than 0')
break
print("Guess the number:")
choice = int(input())
if choice <= 1:
print('Your Choice has to be greater than 0')
break
correctNumber = random.randint(0,maxNum)
if choice == correctNumber:
print('CORRECT')
break
else:
print('WRONG')
except:
ValueError
print('Enter a number, not something else you idiot')
And here the same code but the user only has 3 retries: (The indentations can be wrong if you copy paste my code)
import random
retry = 3
while retry != 0:
try:
print("Welcome to GUESS THE NUMBER. Up to what number would you like to go to?")
maxNum = int(input())
if maxNum <= 1:
print('Number has to be greater than 0')
break
print("Guess the number:")
choice = int(input())
if choice <= 1:
print('Your Choice has to be greater than 0')
break
correctNumber = random.randint(0,maxNum)
if choice == correctNumber:
print('CORRECT')
break
else:
print('WRONG')
retry -= 1
except:
ValueError
print('Enter a number, not something else you idiot')
if retry == 0:
print('You LOOSER')