April 2017
Beginner to intermediate
312 pages
7h 23m
English
Two lists can be combined together using the extend() method. The day_of_week and sequence lists can be combined as follows:
>>> day_of_week.extend(sequence) >>> day_of_week ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 1, 2, 3, 4, 5, 6]
Lists can also be combined as follows:
>>> [1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6]
It is also possible to add a list as an element to another list:
sequence.insert(6, [1, 2, 3]) >>> sequence [1, 2, 3, 4, 5, 6, [1, 2, 3]]
Read now
Unlock full access