Asked • 05/28/19

How do I parse a string to a float or int in Python?

In Python, how can I parse a numeric string like `"545.2222"` to its corresponding float value, `545.2222`? Or parse the string `"31"` to an integer, `31`?I just want to know how to parse a *float* `str` to a `float`, and (separately) an *int* `str` to an `int`.

1 Expert Answer


Zac H. answered • 05/28/19

New to Wyzant

A Data Scientist with the world leader in Education Services

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.