Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Python | Convert List of String List to String List
Next article icon

Python – List of float to string conversion

Last Updated : 28 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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 neatly. Let’s explore different methods to perform this conversion.

Using map()

map() function provides a very efficient way to convert all elements of a list. It applies the str() function to each element of the list.

Python
a = [1.23, 4.56, 7.89]  # Convert using map b = list(map(str, a))  print(b) 

Output
['1.23', '4.56', '7.89'] 

Explanation:

  • map() applies the str() function to each element of the list a.
  • The result is then converted back into a list using list().
  • This method is concise and efficient for large lists.

Let’s explore some more ways and see how we can convert list of float to string in Python.

Table of Content

  • List Comprehension
  • Using for Loop
  • Using join() with map()
  • Using numpy

List Comprehension

List comprehension is a Pythonic way to iterate over the list and convert each element to a string.

Python
a = [1.23, 4.56, 7.89]  # Convert using list comprehension b = [str(i) for i in a]  print(b) 

Output
['1.23', '4.56', '7.89'] 

Explanation:

  • List comprehension iterates through the list a and applies str(i) to each element.
  • The result is a new list b where all float elements are converted to strings.
  • This method is easy to understand and is preferred when you want more control over the conversion process.

Using for Loop

Using a for loop provides a more explicit way of converting elements in a list. This method is less concise but is useful when we want more customization.

Python
a = [1.23, 4.56, 7.89]  # Convert using for loop b = [] for i in a:     b.append(str(i))  print(b) 

Output
['1.23', '4.56', '7.89'] 

Explanation:

  • A for loop iterates through each element of the list a.
  • The str(i) is applied inside the loop, and the results are appended to the new list b.

Using join() with map()

If we need to convert the list of floats to a single string where each element is separated by a specific delimiter, we can use map() along with str.join().

Python
a = [1.23, 4.56, 7.89]  # Convert and join elements as a string b = ', '.join(map(str, a))  print(b) 

Output
1.23, 4.56, 7.89 

Explanation:

  • map(str, a) converts each element of the list to a string.
  • join() concatenates the string elements of the list, separating them by the delimiter , (comma and space).
  • This method is useful when you want to output the list as a single formatted string.

Using numpy

If the list is a numpy array, we can use numpy.vectorize() to perform the conversion efficiently.

Python
import numpy as np  a = np.array([1.23, 4.56, 7.89])  # Convert using numpy.vectorize b = np.vectorize(str)(a)  print(b) 

Output
['1.23' '4.56' '7.89'] 

Explanation:

  • numpy.vectorize() applies str() to each element in the numpy array.
  • This method is efficient when working with numpy arrays, and the result is a numpy array of strings.
  • This approach is mainly useful for those already working within the numpy ecosystem.


Next Article
Python | Convert List of String List to String List
author
manjeet_04
Improve
Article Tags :
  • Python
  • Python Programs
  • Python list-programs
Practice Tags :
  • python

Similar Reads

  • Convert String Float to Float List in Python
    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
    3 min read
  • 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 | 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 List of String List to String List
    Sometimes while working in Python, we can have problems of the interconversion of data. This article talks about the conversion of list of List Strings to joined string list. Let's discuss certain ways in which this task can be performed. Method #1 : Using map() + generator expression + join() + isd
    6 min read
  • Convert list of strings to list of tuples in Python
    Sometimes we deal with different types of data types and we require to inter-convert from one data type to another hence interconversion is always a useful tool to have knowledge. This article deals with the converse case. Let's discuss certain ways in which this can be done in Python. Method 1: Con
    5 min read
  • Python - Summation of float string list
    Sometimes, while working with Python list, we can have a problem in which we need to find summation in list. But sometimes, we don’t have a natural number but a floating-point number in string format. This problem can occur while working with data, both in web development and Data Science domain. Le
    7 min read
  • Python - Convert List of Integers to a List of Strings
    We are given a list of integers and our task is to convert each integer into its string representation. For example, if we have a list like [1, 2, 3] then the output should be ['1', '2', '3']. In Python, there are multiple ways to do this efficiently, some of them are: using functions like map(), re
    3 min read
  • Convert JSON to string - Python
    Data is transmitted across platforms using API calls. Data is mostly retrieved in JSON format. We can convert the obtained JSON data into String data for the ease of storing and working with it. Python provides built-in support for working with JSON through the json module. We can convert JSON data
    2 min read
  • Python | Convert string enclosed list to list
    Given a list enclosed within a string (or quotes), write a Python program to convert the given string to list type. Examples: Input : "[0, 2, 9, 4, 8]" Output : [0, 2, 9, 4, 8] Input : "['x', 'y', 'z']" Output : ['x', 'y', 'z'] Approach #1: Python eval() The eval() method parses the expression passe
    5 min read
  • Python | Convert String to tuple list
    Sometimes, while working with Python strings, we can have a problem in which we receive a tuple, list in the comma-separated string format, and have to convert to the tuple list. Let's discuss certain ways in which this task can be performed. Method #1 : Using loop + split() + replace() This is a br
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences