Append index | Sololearn: Learn to code for FREE!


Append index

what's the difference between append and index

7/23/2017 1:45:39 PM


2 Answers

New Answer


append is a method to add element in a list for example. And once added, the element will have an index. Here is an example list = [1, 2, 6] list.append(7) [1, 2, 6, 7] the added number 7 is at index 3


.append(n) adds n to the list, while .index(n) just returns the place where n is in the list (first ocurrence; if it is in the list at all)