Hi I am trying to print the data type of a user input and produce a table like following:
ABCDEFGH = String, 1.09 = float, 0 = int, true = bool
Input will always return a string. You need to evaluate the string to get some Python value:
>>> type(eval(raw_input()))
23423
>>> type(eval(raw_input()))
"asdas"
>>> type(eval(raw_input()))
1.09
>>> type(eval(raw_input()))
True
If you want safety (here user can execute arbitrary code), you should use ast.literal_eval
:
>>> import ast
>>> type(ast.literal_eval(raw_input()))
342
>>> type(ast.literal_eval(raw_input()))
"asd"