0

Why insert doesn't work as append?

I know it's crazy. But with my curiosity I want to know why it doesn't add 'is' to last index in the list https://code.sololearn.com/c1V5nZpjskeK/?ref=app

27th Aug 2019, 4:40 PM
Bawantha Nawela
Bawantha Nawela - avatar
2 odpowiedzi
+ 3
If you look a the documentation (https://docs.python.org/3/tutorial/datastructures.html#more-on-lists) you can read: “... Insert an item at a given position. The first argument is the index of the element before which to insert ...”
27th Aug 2019, 4:47 PM
Michael
Michael - avatar
+ 1
Bawantha Nawela. Try words.insert(len(words), "is")
27th Aug 2019, 6:41 PM
portpass