Formation of a string by combining several characters of a list

Submitted 3 years, 7 months ago
Ticket #172
Views 190
Language/Framework Python
Priority Low
Status Closed

I have a list of characters like 

a = ['he','ll','o','  ','good','mo','rni','n','g']

I want te final output as

hello  goodmorning

could anyone help me???

Submitted on Sep 16, 20
add a comment

2 Answers

a = ['he','ll','o','  ','good','mo','rni','n','g']
print(''.join(a))
arr = [23, 10, 12, 5, 13,19]
print(''.join(map(str, arr)))

so if you see this by using join() we can convert different characters into a string

If we want to convert the elements of array into a string we use map() function along with join() function

If you check the output of the above code we get:

hello  goodmorning
23101251319

Submitted 3 years, 7 months ago

>>> a = ['a', 'b', 'c', 'd']
>>> ''.join(a)

Submitted 3 years, 7 months ago


Latest Blogs