Posts Tagged ‘Extend’

How to append two lists in Python?

We can use a list’s extend() function to append another list. c1 = ["Red","Green","Blue"] c2 = ["Orange","Yellow","Indigo"] c1.extend(c2)   assert c1 == ["Red","Green","Blue","Orange","Yellow","Indigo"] Lists can also be appended using the + operator. c1 = ["Red","Green","Blue"] c2 = ["Orange","Yellow","Indigo"] c3 = c1 + c2   assert c3 == ["Red","Green","Blue","Orange","Yellow","Indigo"]