I've been trying to write a simple checking script for whatever the user inputs.
The script, however, automatically assumes that anything being input is a string by default. Is there a way to change that without using int(input)
or float(input)
? The point of the script is to use the isinstance
to get the correct output.
l = input("Input: ")
if isinstance(l, int) and l >= 0:
print ("l is %d and is more/equal to zero" % l)
elif isinstance(l, int) and l < 0:
print ("l is %d and is lesser than zero" % l)
elif isinstance(l, float):
print ("l is %.2f and is a float variable" % l)
elif isinstance(l, str):
print ("l is %s and is a string" % l)