class str(object)
...
Create a new string object from the given object.
Meaning
if bet == str():
Will check bet
against the result of str()
which is an empty string. Also, using input
will always give you a string, so there is no need to check whether it is a string. If you enter 1
for instance, you will get the string "1"
. If you want to verify the user input was indeed a number, you'll need other checks, for instance:
import string
foo = input('foo: ')
if not foo in string.digits:
...
or
foo = input('foo: ')
try:
bar = int(foo)
except ValueError:
print("This wasn't a number.")
You'll likely want to put your input
in your loop as well, if I understand your intentions correctly. For instance:
saldo = 1000
while True:
bet = input('bet: ')
try:
foo = int(bet)
break
except:
print("This wasn't a number, try again.")