933 points
8 4 2


Hello guys,

I am new to python programming language I basically come from c language background. I am having a problem while working with python strings. Anyway, in my program, I have got a situation where I need to convert a float into a python string. For example, if the user input is:

flt =123497.124

Is it possible to convert the float to string I am really confused about it waiting for some help as soon as possible this is getting me in a bit of trouble?


Python string has a built-in function named Str( ) method. The string method is used to convert the float point number to the string and use them wherever necessary. The built-in method returns a string of the words, using the “delimiter” as the delimiter string. But you have to keep in mind that internal it should be floating point number only still any data structure can be converted to the string. As per your requirement, you want to do this:

def Convert(float):
	is_a_str = str(float)
	return is_a_str

flt = 123.45



You can even check the type of this new float converted to string with the help of type( ) function present in it, I hope this is going to help you. Happy coding!!

More Posts

Python checks if the string is integer or float. Farkhanda Athar - Jul 17, 2020
Python float('inf') Farkhanda Athar - Aug 2, 2020
Typeerror: cannot convert the series to <class 'float'>. Farkhanda Athar - Jul 8, 2020
How to find the last occurrence of character in string python ? Naymul01 - 3 days
How to remove duplicate characters in a string python? Naymul01 - 3 days
How to find all substrings of a string python? Naymul01 - 3 days
How to append a string in python ? Naymul01 - Oct 19
How to get the first character of a string in python? Naymul01 - Oct 19
How to get last character of string in python? Naymul01 - Oct 19
Python append to string in loop Naymul01 - Oct 19