how to create a string from a list in python code example

Example 1: how to make a list string in python

n = ["Hello"," I'm " , "12" , " Years Old "] # Our list
String = "" # Our string
for x in n :
    String += x
    
print(String) #Prints it

Example 2: python array to string

mystring = 'hello, world'

myarray = string1.split(', ') #output => [hello, world]

myjoin1 = ', '.join(myarray) #output => hello, world
myjoin2 = ' '.join(myarray) #output => hello world
myjoin3 = ','.join(myarray) #output => hello,world

Example 3: python list to string

mystring = 'hello, world'

mylist = string1.split(', ') #output => ['hello', 'world']

myjoin1 = ', '.join(mylist) #output => 'hello, world'
myjoin2 = ' '.join(mylist) #output => 'hello world'
myjoin3 = ','.join(mylist) #output => 'hello,world'

Tags:

Java Example