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? ')
Run Code Online (Sandbox Code Playgroud)
这仅在用户输入时才有效integer,但我希望即使他们输入了一个,但我希望它能够工作float,而不是在他们输入时string.
因此,用户应该能够同时输入9和9.2,但不会abc.
我该怎么办?