Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Lists Meet Lists Indexing

Igor Dias
Igor Dias
5,155 Points

Problem adding an iten in the end of the list using insert

names = ["john","bill","gabriel"] numbers.insert(-1, "Ana")

Why this does not work?

3 Answers

Tabatha Trahan
Tabatha Trahan
21,422 Points

It looks like you may just have called the insert method on the wrong variable name. You declared a list of values called name, but you called the insert method on a list with the name of numbers.

Vincient Degala
Vincient Degala
1,616 Points

names = ["john", "bill", "gabriel"] names.insert(-1, "Ana")

try this

You called the insert function on an undefined variable called number, probably because you indexed and got confused