Languages
[Edit]
EN

Python - convert string to double

0 points
Created by:
Antonina-Trejo
237

Unfortunately, there are no doubles in Python. You can use float that behaves like a double as an alternative solution.

Quick solution:

number = "1.234"
result = float(number)

print(type(result))  # <class 'float'>

or:

from decimal import Decimal

number = "1.234"
result = Decimal(number)

print(type(result))  # <class 'decimal.Decimal'>

See also

Python - string (popular problems)

Python - convert string to double
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join