Identify the variable type
def what_type(g):
x = str(type(g))
if "int" in x:
return "int"
elif "str" in x:
return "str"
elif "bool" in x:
return "bool"
elif "float" in x:
return "float"
Function Call | Return Value | |||
---|---|---|---|---|
what_type(3.1415) | → | |||
what_type(3) | → | |||
what_type(3.0) | → | |||
what_type("Hello") | → | |||
what_type(False) | → |
Experiment with this code on Gitpod.io