Thanks for your clues 。
From you input ,I finally realize the bug is that the false still trigger next step “return int”
value.isdigit()==True
return "int"
According to this ,I modify the solution 3 as below and i think it is workable now
Please feel free to commment if any valuable input ,thanks Chris!
def johnnysuper(value):
try:
if value.isdigit():
return “int”
elif int(value)<0:
return “int”
else:
pass
except ValueError:
pass
try:
float(value)
return “float”
except ValueError:
return “str”
value=input(“Please input :”)
print(johnnysuper(value))