Python Convert String to Float

Last Updated On Thursday 20th Jan 2022

Convert String to Float Python

python cast string to int.We can convert a string to float in Python using float() function. It’s a built-in function to convert an object to floating point number.


The float() method returns a floating point number from a number or a string.

float() Syntax

The syntax for float() is:


how to convert string to float in python


  • It can be an int, float, or string.
  • If it is a string, then it must be of correct decimal format.


  • It returns a float object.
  • If no argument is provided, then it returns 0.0.
  • If the given argument is outside the range of float, it raises overflow Error.
	intNum = 44

# convert int to float
floatNum = float(intNum)
print(floatNum) # Output: 44.0

python convert string to number

	strr = '44.8765'

flt = float(strr)

	<class 'float'>

string to float python

	string = '96.9968'

flt = float(string)

print('Value =', flt)
	<class 'float'>
Value = 96.9968