filmov
tv
python join/merge list two and more lists

Показать описание
python join and merge list 4 examples
Two list can be merge in python in many ways:
listOne + listTwo
[*listOne, *listTwo]
list(set(listOne + listTwo))
#
# simple list merge
#
listOne = [1, 2, 3, 7, 9]
listTwo = [4, 5, 6, 7, 8]
listThree = ['a', 'b']
listSimple = listOne + listTwo
print ('list merge: ', listSimple)
#
# join list by extent
#
listExtend = []
print('extent: ', listExtend)
#
# merge list python 3.5 and above
#
joinedList = [*listOne, *listTwo]
print('Unpacking Generalizations: ', joinedList)
#
# remove duplicates on merge
#
listNoDuplicates = list(set(listOne + listTwo))
print('unique: ', listNoDuplicates)
#
# merge list more than 2
#
listSimple = listOne + listTwo + listThree
joinedList = [*listOne, *listTwo, *listThree, ]
-----------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Code store
Socials
If you really find this channel useful and enjoy the content, you're welcome to support me and this channel with a small donation via PayPal.
Two list can be merge in python in many ways:
listOne + listTwo
[*listOne, *listTwo]
list(set(listOne + listTwo))
#
# simple list merge
#
listOne = [1, 2, 3, 7, 9]
listTwo = [4, 5, 6, 7, 8]
listThree = ['a', 'b']
listSimple = listOne + listTwo
print ('list merge: ', listSimple)
#
# join list by extent
#
listExtend = []
print('extent: ', listExtend)
#
# merge list python 3.5 and above
#
joinedList = [*listOne, *listTwo]
print('Unpacking Generalizations: ', joinedList)
#
# remove duplicates on merge
#
listNoDuplicates = list(set(listOne + listTwo))
print('unique: ', listNoDuplicates)
#
# merge list more than 2
#
listSimple = listOne + listTwo + listThree
joinedList = [*listOne, *listTwo, *listThree, ]
-----------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Code store
Socials
If you really find this channel useful and enjoy the content, you're welcome to support me and this channel with a small donation via PayPal.