0
x=input('Enter input:')
print (type(x))
if type(x)==type(""):
    print ("It is a string")
elif type(x)==type(1):
    print ("It is an integer")
elif type(x)==type(1.0):
    print ("It is a floating point")
else:
    print ("It is other than integer,floating point and string")

Every time I run this program, <class 'str'> and 'It is a string' comes as output.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • `input` always returns a string in 3.X. If you want it to return something else, downgrade to 2.7. – Kevin Mar 18 '15 at 15:10
  • Even in 2.x you shouldn't be using `input`. Use `raw_input` (which in 2.x has the same behaviour as `input` in 3.x), then *explicitly convert* (using e.g. `int`, `float`, or `ast.literal_eval`) if the user input represents some other object. – jonrsharpe Mar 18 '15 at 15:12

0 Answers0