0
Can you explain the following circumstances in python3?
why does typecasting of string into integer work in the following code x=int(input("enter no.") while it doesn't work in this one: print(int("4.5"))
2 ответов
+ 3
If your input is 4.5 (is a float) you will get the same error on the input line.
+ 1
4.5 is real value so you have to use float here.
print(float("4.5"))