Here i add validator for each entry to avoid the errors in the inputs, next i add a bucle while that works everytime you have money
import random
money = 50
while money>0:
while True:
try:
bet = int(input(f"You have {money} dollars, how much money would you like to bet? "))
if bet > money:
print("You don't have all that money!")
elif bet <= money:
money = money - bet
break
except ValueError:
print("You don't have all that money!")
while True:
try:
guess = int(input("Choose one number in between 1 and 10: "))
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
if guess in numbers:
break
except:
print("You don't choose a correct number")
random_numbers = random.choice(numbers)
print("The number drawn was:", random_numbers, "!")
if guess == random_numbers:
money = money + 2*bet
print("Congratulations! You guessed right and doubled you bet! You now have:", money, "!")
else:
print("You guessed wrong and lost the value that you bet. You now have:", money, ".")
if money == 0:
break
while True:
try:
ans = input("Would like to play again? yes/no: ")
if ans == "yes" or ans == " no":
break
except:
print("You don't wire a correct answer")
if ans == "yes":
print("Let's try again")
else:
print("Goodbye Friend")
break
print("Sorry friend you WASTED")