June 2017
Beginner
352 pages
8h 39m
English
Items can be inserted into lists using the insert() method, which accepts the index of the new item and the new item itself:
>>> a = 'I accidentally the whole universe'.split()>>> a['I', 'accidentally', 'the', 'whole', 'universe']>>> a.insert(2, "destroyed")>>> a['I', 'accidentally', 'destroyed', 'the', 'whole', 'universe']>>> ' '.join(a)'I accidentally destroyed the whole universe'
Read now
Unlock full access