How to get floating point number from a string in Python

1 Answer

0 votes
s = "12"
f = float(s)
print(f)

s = "3.14"
f = float(s)
print(f)

s = "       17.39\n"
f = float(s)
print(f)


    
    
    

'''
run:

12.0
3.14
17.39

'''

 



answered Apr 26, 2021 by avibootz

Related questions

...