
- 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
How to convert list to string in Python?
There may be some situations, where we need to convert a list into a string. We will discuss different methods to do the same.
Iteration
Iterate through the list and append the elements to the string to convert list into a string. We will use for-in loop to iterate through the list elements.
Example
list1=["Welcome","To","Tutorials","Point"] string1="" for i in list1: string1=string1+i string2="" for i in list1: string2=string2+i+" " print(string1) print(string2)
Output
WelcomeToTutorialsPoint Welcome To Tutorials Point
Using .join() method
The list will be passed as a parameter inside the join method.
Example
list1=["Welcome","To","Tutorials","Point"] string1="" print(string1.join(list1)) string2=" " print(string2.join(list1))
Output
WelcomeToTutorialsPoint Welcome To Tutorials Point
Using map()
We can use map() method for mapping str with the list and then use join() to convert list into string.
Example
list1=["Welcome","To","Tutorials","Point"] string1="".join(map(str,list1)) string2=" ".join(map(str,list1)) print(string1) print(string2)
Output
WelcomeToTutorialsPoint Welcome To Tutorials Point
Using list comprehension
Comprehensions in Python provide a short way to construct new sequences using already provided sequences. We will access each element of the list as a string and then use join().
Example
list1=["Welcome","To","Tutorials","Point"] string1="".join(str(elem) for elem in list1) string2=" ".join(str(elem) for elem in list1) print(string1) print(string2)
Output
WelcomeToTutorialsPoint Welcome To Tutorials Point
- Related Articles
- Convert string enclosed list to list in Python
- Convert list of string to list of list in Python
- Python - Convert list of string to list of list
- Convert a list to string in Python program
- Python program to convert a list to string
- How to convert a string to a list of words in python?
- Convert list of numerical string to list of Integers in Python
- How to convert a list to string in C#?
- How to convert list to dictionary in Python?
- How to convert string to binary in Python?
- How to convert int to string in Python?
- How to convert Python Dictionary to a list?
- How to convert a string to dictionary in Python?
- Convert a string representation of list into list in Python
- How to convert string to JSON using Python?

Advertisements