How to convert list to String in Python

In this post, we will see how can you convert list to String in python.

There are many ways to do it.

  • Using join method
  • Using iterative method

Using join method

l=[1,2,3,4] st=''.join(str(s) for s in l) print("Using join and for loop:",st) #you can use map method too st1=''.join(map(str, l)) print("Using join and map:",st1) #In case if you want comma separated String st2=','.join(map(str, l)) print("Comma separated String:",st2)

Output:

Using join and for loop: 1234
Using join and map: 1234
Comma separated String: 1,2,3,4

Using iterative method

l=[1,2,3,4] strList= "" for i in l: strList += str(i) print(strList)

Output:

1234

That’s all about How to convert list to String in Python.

Leave a Reply

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