Suppose I have a string:
temp = "0.1"
When I run int(temp):
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '0.1'
But when I run int(float(temp)):
I get the correct output i.e. 0
Why does converting to float and then converting to int work but directly converting to int not work ?
Thanks and regards