0
How can I convert string to float? in python.
I want to take an input which is may be a float.
2 Respostas
+ 3
Since inputs are by default string type, you can easily cast them to float like this.
num = float(input())
0
x = input()
if isinstance(x, float):
x = float(x)