Python - Joining unicode list elements


In this article, we are going to learn how to join Unicode list elements. Follow the below steps to write the code.

  • Initialize the list.
  • Convert all the elements into Unicode using map and string.encode methods.
  • Convert each encoded string using the decode method.
  • Join the strings using join method.
  • Print the result.

Example

 Live Demo

# initializing the list
strings = ['Tutorialspoint', 'is a popular', 'site', 'for tech leranings']

def get_unicode(string):
return string.encode()

# converting to unicode
strings_unicode = map(get_unicode, strings)

# joining the unicodes
result = ' '.join(unicode.decode() for unicode in strings_unicode)

# printing the result
print(result)

If you run the above code, then you will get the following result.

Output

Tutorialspoint is a popular site for tech leranings

Conclusion

If you have any queries in the article, mention them in the comment section.

Updated on: 13-Nov-2020

263 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements