Answers for "concatenate two list in python"

5

add two list in python

list1 = ["a", "b" , "c"]
list2 = [1, 2, 3]

list1.extend(list2)
print(list1)
Posted by: Guest on May-17-2020
2

python concatenate list of lists

x = [["a","b"], ["c"]]

result = sum(x, [])
Posted by: Guest on July-04-2020
0

merge lists in list python

import itertools
a = [['a','b'], ['c']]
print(list(itertools.chain.from_iterable(a)))
Posted by: Guest on June-03-2020
0

how to concatenate two lists in python

list1 = ["Hello ", "take "]
list2 = ["Dear", "Sir"]

resList = [x+y for x in list1 for y in list2]
print(resList)

#['Hello Dear', 'Hello Sir', 'take Dear', 'take Sir']
Posted by: Guest on July-06-2021
0

how to combine 2 lists in python

l1 = [1,2,3,4]
l2 = [1,1,1,1]
l3 = [l1[x//2] if x % 2 == 0 else l2[x//2] for x in range(8)]
// l3: [1, 2, 3, 4, 5, 6, 7, 8]
Posted by: Guest on May-03-2021

Code answers related to "concatenate two list in python"

Python Answers by Framework

Browse Popular Code Answers by Language