You can use in-built function float() or int() to parse a string to a float or int as shown in the below example –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
pai = "3.1415926" f = float(pai) print(f) print(type(f)) i = int(f) print(i) print(type(i)) ## Returns ## 3.1415926 ## ## 3 ## |