
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to convert a list to string
In this article, we will learn about the solution and approach to solve the given problem statement.
Problem statement
Given a list we need to convert into a string type.
Here we will be discussing four different approaches to solve the problem statement given above −
Approach 1: Using concatenation in an empty string.
Example
def listToString(s): # empty string str1 = "" # traversal for ele in s: str1 += ele # return string return str1 # main s = ['tutorials’,’point’] print(listToString(s))
Output
tutorialspoint
Approach 2: Using .join() function
Example
def listToString(s): # initialize an empty string str1 = " " # return string return (str1.join(s)) # Driver code s = ['tutorials’,’point’] print(listToString(s))
Output
tutorialspoint
Approach 3: Using list comprehension
Example
s = ['tutorials’,’point’] # using list comprehension listToStr = ' '.join([str(elem) for elem in s]) print(listToStr)
Output
tutorialspoint
Approach 4: Using map() function
Example
s = ['tutorials’,’point’] # using list comprehension listToStr = ' '.join(map(str, s)) print(listToStr)
Output
tutorialspoint
Conclusion
In this article, we learned about the approach to convert list to string.
- Related Articles
- Convert a list to string in Python program
- Convert string enclosed list to list in Python
- Python - Convert list of string to list of list
- Java Program to Convert a List of String to Comma Separated String
- How to convert list to string in Python?
- Convert list of string to list of list in Python
- Python Program to Convert Matrix to String
- Python Program to Convert a given Singly Linked List to a Circular List
- Java program to convert a list of characters into a string
- C# program to convert a list of characters into a string
- Program to convert List of Integer to List of String in Java
- Program to convert List of String to List of Integer in Java
- How to convert a string to a list of words in python?
- Python program to convert hex string to decimal
- Convert list of numerical string to list of Integers in Python

Advertisements