I recieve data in string format:
input1 = ",1"
input2 = "1,"
I need to convert it into float and validate it in my tests. I expect this kind of convertion:
",1" -> 0.1
"1," -> 1.0
Is it possible without using regular expressions?
I recieve data in string format:
input1 = ",1"
input2 = "1,"
I need to convert it into float and validate it in my tests. I expect this kind of convertion:
",1" -> 0.1
"1," -> 1.0
Is it possible without using regular expressions?
You can substitute the ,
with .
using replace()
and then convert to float
float(input1.replace(',','.'))