concatenate list

27

#python 3.x
words_list = ['Joey', 'doesnot', 'share', 'food']
print(" ".join(words_list))
sample_list1 = [0, 1, 2, 3, 4] 
sample_list2 = [5, 6, 7, 8] 
 
result = sample_list1 + sample_list2 
 
print ("Concatenated list: " + str(result))
x = [["a","b"], ["c"]]

result = sum(x, [])
'separator'.join([ 'List','of',' string' ])
sum([[1, 2, 3], [4, 5, 6], [7], [8, 9]],[])
# [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a = [1, 2, 3]
>>> b = [4, 5, 6]
>>> c = a + b
>>> print(c)
[1, 2, 3, 4, 5, 6]

Comments

Submit
0 Comments