I just started learning python 2 days ago and I am trying to make my very first bit of working code but I can't figure this out!!
I'm making a basic dice game and want to allow the user to 'bet' an amount of virtual money but want to prevent them from being able to insert something which is not an integer. This is what I came up with:
bet = input ('How much would you like to bet this round? (It can be 0) ')
while bet!=int or bet>gold or bet<0 :
time.sleep (1)
print ("\nInvalid bet amount! Try betting a different amount.")
bet = input ('How much would you like to bet this round? (It can be 0) ')
The issue I have (I think) is that the bet input is taken as a string and so will always not be an integer, leading to an inescapable loop of an invalid bet amount. If I try to say that the bet = int(input('How much would you like to bet this round?') however, the user could still input a letter and cause an error because I've stated the bet has to be an integer.
Any ideas how to bypass this?? Also please let me know if there's anything I could do better in the code I've shown. I'm a complete beginner and happy to learn :)
Thanks!