Convert Characters to String

Tags: List, String

Given a list of characters, write a Python program to convert the list of characters into a string.

Example 1:

Input: ['H','e','l','l','o'] 
Output: 'Hello'

Example 2:

Input: ['W','o','r','l','d'] 
Output: 'World'

You can use Python’s built-in join() function to join the characters into a string.

def convert_to_string(chars):
    return ''.join(chars)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!