Byvoeging aan 'n lys in Python

Ons kan ook twee lyste saamvoeg, terwyl die oorspronklike een verander word. In sulke gevalle gebruik ons die += operator:

pythonlst1 = [1, 2, 3]
lst2 = [4, 5, 6]

lst1 += lst2
print(lst1) # sal [1, 2, 3, 4, 5, 6] druk
Задание 1

Twee lyste word gegee:

pythonlst1 = ['12', '34', '56']
lst2 = ['ab', 'cd', 'ef']

Voeg hulle saam.

Задание 2

Twee lyste word gegee:

pythonlst1 = ['a', 'b', 'c']
lst2 = [4, 5, 6]

Voeg die eerste lys by die tweede.