Skip to content
Advertisement

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

  • How can I convert a str to float?
    JavaScript
  • How can I convert a str to int?
    JavaScript

For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it.

Please instead use How can I read inputs as numbers? to close duplicate questions where OP received a string from user input and immediately wants to convert it, or was hoping for input (in 3.x) to convert the type automatically.

Advertisement

Answer

JavaScript
Advertisement