How to Join Words in List Python?

Share This Post

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)

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

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

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

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?


Related Posts

Python for Loop Iteration: How to Easily Manipulate a List

One of the most powerful features of the Python...

How To Get First Characters of a String in Python

Way to find the first characters of a string...

How To Convert Tuple To String In Python

In this post, you will learn how to convert...

How To Convert String to Double in Python

Good to hear, that you want to convert a...

Python TypeError: String Index Out Of Range Solution

A string is an array of characters and part...

How To Remove Empty Strings From a List Of Strings

On this page, we will discuss how to remove...
- Advertisement -spot_img