How to convert string to Int or Float in Python

To convert string to Int or Float in Python you can use the following snippet.

Sample Python

NumbertoConvert = "321.1234"
print(float(NumbertoConvert)) # prints out 321.1234
print(int(float(NumbertoConvert))) # prints out 321

Please Share us:
Please rate this snippet

3 thoughts on “How to convert string to Int or Float in Python

Leave a Reply