a = raw_input('How much is 1 share in that company? ')
while not a.isdigit():
print("You need to write a number!\n")
a = raw_input('How much is 1 share in that company? ')
Это работает только в том случае, если пользователь вводит integer
, но я хочу, чтобы он работал, даже если они вводят float
, но не когда они вводят string
.
Таким образом, пользователь должен иметь возможность вводить как 9
, так и 9.2
, но не abc
.
Как мне это сделать?