A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-convert-list-characters-string/ below:

Convert a List of Characters into a String - Python

Convert a List of Characters into a String - Python

Last Updated : 21 Feb, 2025

Try it on GfG Practice

Our task is to convert a list of characters into a single string. For example, if the input is ['H', 'e', 'l', 'l', 'o'], the output should be "Hello".

Using join() 

We can convert a list of characters into a string using join() method, this method concatenates the list elements (which should be string type) into one string.

Python
a = ['P', 'y', 't', 'h', 'o', 'n']

# Convert list of characters to string
s = ''.join(a)

print(s)

Explanation: ''.join(a) joins all elements in a using an empty string as the separator.

Using reduce()

reduce() function applies a function cumulatively to the elements of the list, reducing them to a single value.

Python
from functools import reduce

a = ['P', 'y', 't', 'h', 'o', 'n']

res = reduce(lambda x, y: x + y, a)

print(res)

Explanation:

Using for Loop

If we want to join all the characters of the given list without using any inbuilt method then we can use a for loop.

Python
a = ['P', 'y', 't', 'h', 'o', 'n']

s = ''

# Loop through each character in list 'a' and add it to string 's'
for c in a:
    s += c

print(s)

Explanation: Iterates through a, adding each character to res and builds the final string step by step.


Convert a list of characters into a string in Python


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4