#Here is part of my code. money = 100
def bet():
print(f"You have ${money}.")
print("How many would you like to bet?")
bet = int(input())
while not bet > 0 or not bet < money: #It gives me error if i wrote < or >.
print(f"Type the value between [1]-[{money}].")
bet()
else:
game(bet)
You don't need recursion, so even though you are creating a local variable with the same name as your function, that's OK, because you won't need the name of your function.
def bet():
while True:
print(f"You have ${money}.")
print("How many would you like to bet?")
bet = int(input())
if 0 < bet <= money:
break
print(f"Type the value between [1]-[{money}].")
game(bet)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.