Skip to content

How to Join Words in List Python?

  • by
Join Words in List Python?

Either you can use join built-in Python function to marge two or multiple words in list using Python.

How to Join Words in List Python?


l = ['aaa', 'bbb', 'ccc']

s = ''.join(l)
print(s)

# aaabbbccc
s = ','.join(l)
print(s)

# aaa,bbb,ccc
s = '-'.join(l)
print(s)

# aaa-bbb-ccc
s = '\n'.join(l)
print(s)

You can visit the source code: here

And here is a simple executable way to do it:


list = ['Add', 'Wholeblogs', 'Answer']
joined = " ".join(list)
seperator = ", "
joined = seperator.join(list)

Add, Wholeblogs, Answer

By adding some simple code you will be able to see the result according you want. Let’s have a new example in our words like:

  • Create a list.
  • Make a new variable.
  • Use join built-in function.
  • Merge them together.
  • Now print out that variable.

That’s it. done!

Read ahead: How to recover from messed-up Python installation on a Mac?

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *