Convert String Float to Float List in Python Last Updated : 06 Feb, 2025 Comments Improve Suggest changes Like Article Like Report We are given a string float we need to convert that to float of list. For example, s = '1.23 4.56 7.89' we are given a list a we need to convert this to float list so that resultant output should be [1.23, 4.56, 7.89].Using split() and map()By using split() on a string containing float numbers, we can break it into individual string elements and then apply map() to convert each element into a float. This produces a list of floats derived from the original string. Python s = '1.23 4.56 7.89' # Split the string 's' into a list of substrings and convert each substring to a float using map f = list(map(float, s.split())) print(f) Output[1.23, 4.56, 7.89] Explanation:s.split() splits the string s at each space, producing a list of string representations of the float values.map(float, ...) applies the float function to each element of the list, converting the strings to floats, and list() creates a list from the resulting map object.Using List ComprehensionWe can split a string into individual elements and convert each element to a float in one line using list comprehension, resulting in a concise list of float values from the original string. Python s = '1.23 4.56 7.89' # Define a string 's' containing float values separated by spaces # Use list comprehension to split the string and convert each element to a float f = [float(x) for x in s.split()] print(f) Output[1.23, 4.56, 7.89] Explanation:s.split() splits the string s into a list of substrings, each representing a float value, based on spaces.The list comprehension [float(x) for x in s.split()] converts each substring into a float and stores the results in the list f.Using re.split()re.split() function can be used to split a string based on a regular expression pattern (such as spaces or other delimiters) and then map() or a list comprehension can convert each substring into a float. This method provides greater flexibility in handling different delimiters when splitting the string. Python import re s = '1.23,4.56;7.89' # Use re.split() to split the string by both commas and semicolons f = [float(x) for x in re.split('[,;]', s)] print(f) Output[1.23, 4.56, 7.89] Explanation:re.split('[,;]', s) splits the string s at both commas and semicolons, using the regular expression pattern [ , ; ] to match these delimiters.The list comprehension [float(x) for x in re.split('[,;]', s)] converts each substring (split by the delimiters) into a float and stores them in the list f. Comment More infoAdvertise with us Next Article Convert String Float to Float List in Python manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Convert Float String List to Float Values-Python The task of converting a list of float strings to float values in Python involves changing the elements of the list, which are originally represented as strings, into their corresponding float data type. For example, given a list a = ['87.6', '454.6', '9.34', '23', '12.3'], the goal is to convert ea 3 min read Python - List of float to string conversion When working with lists of floats in Python, we may often need to convert the elements of the list from float to string format. For example, if we have a list of floating-point numbers like [1.23, 4.56, 7.89], converting them to strings allows us to perform string-specific operations or output them 3 min read Python | Convert Joint Float string to Numbers Sometimes, while working with Legacy languages, we can have certain problems. One such can be working with FORTRAN which can give text output (without spaces, which are required) '12.4567.23' . In this, there are actually two floating point separate numbers but concatenated. We can have problem in w 5 min read Python - Convert Float to digit list We are given a floating-point number and our task is to convert it into a list of its individual digits, ignoring the decimal point. For example, if the input is 45.67, the output should be [4, 5, 6, 7].Using string manipulationIn this method, the number is converted to a string and then each charac 4 min read Python - Filter float strings from String list Sometimes, while working with Python list, we can have a problem in which we need to separate the float values from valid strings. But problem arises when float values are in form of strings. Let's discuss certain ways in which this task can be performed. Method #1 : Using loop + Exception Handling 8 min read Convert Each Item in the List to String using Python Converting each item in a list to a string is a common task when working with data in Python. Whether we're dealing with numbers, booleans or other data types, turning everything into a string can help us format or display data properly. We can do this using various methods like loops, the map() fun 3 min read How to Convert Binary Data to Float in Python? We are given binary data and we need to convert these binary data into float using Python and print the result. In this article, we will see how to convert binary data to float in Python. Example: Input: b'\x40\x49\x0f\xdb' <class 'bytes'>Output: 3.1415927410125732 <class 'float'>Explana 2 min read Python Program to Convert a List to String In Python, converting a list to a string is a common operation. In this article, we will explore the several methods to convert a list into a string. The most common method to convert a list of strings into a single string is by using join() method. Let's take an example about how to do it.Using the 3 min read How to Add Floats to a List in Python Adding floats to a list in Python is simple and can be done in several ways. The easiest way to add a float to a list is by using the append() method. This method adds a single value to the end of the list.Pythona = [1.2, 3.4, 5.6] #Add a float value (7.8) to the end of the list a.append(7.8) print( 2 min read How To Check If A String Can Be Converted To Float In Python? In Python, determining whether a string can be successfully converted to a float is a common task, especially when dealing with user input or external data. This article explores various methods to check if a string is convertible to a float, providing insights into handling potential exceptions and 3 min read Like