In JavaScript we have +number which converts a string into a number based on its value, as shown below:
x = '123' => +x returns 123
y = '12.3' => +y returns 12.3
Now if I use int in python it returns:
x = '123' => int(x) returns 123
y = '12.3' => int(y) returns 12 which is wrong as it should return 12.3
Whereas if I use float:
x = '123' => float(x) returns 123.0 which is wrong as it should return 123 only though I know 123.0 is same as 123 but I want to parse it to some other query language which identifies the numbers as mentioned above.
y = '12.3' => float(y) returns 12.3