+ 2

Append index

what's the difference between append and index

23rd Jul 2017, 1:45 PM
Darwin
Darwin - avatar
2 Respostas
+ 2
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
23rd Jul 2017, 2:22 PM
Biser Z Ivanov
Biser Z Ivanov - avatar
+ 5
.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)
23rd Jul 2017, 2:21 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar