Answers for "join 2 lists python"

14

python join items in list

l = ['aaa', 'bbb', 'ccc']

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

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

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

s = 'n'.join(l)
print(s)
# aaa
# bbb
# ccc
Posted by: Guest on September-09-2020
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
6

combine to lists python

listone = [1,2,3]
listtwo = [4,5,6]

joinedlist = listone + listtwo
Posted by: Guest on November-19-2019
6

join lists python

first_list = ["1", "2"]
second_list = ["3", "4"]

# Multiple ways to do this:
first_list += second_list
first_list = first_list + second_list
first_list.extend(second_list)
Posted by: Guest on April-17-2020
0

concatenate two lists

# concatenation using naive method 
 
# Initializing lists
test_list1 = [1, 4, 5, 6, 5]
test_list2 = [3, 5, 7, 2, 5]
  
# using naive method to concat
for i in test_list2 :
    test_list1.append(i)
Posted by: Guest on August-12-2021
0

merge two lists python

>>> l1 = [1, 2, 3]
>>> l2 = [4, 5, 6]
>>> joined_list = [*l1, *l2]  # unpack both iterables in a list literal
>>> print(joined_list)
[1, 2, 3, 4, 5, 6]
Posted by: Guest on May-12-2021

Python Answers by Framework

Browse Popular Code Answers by Language