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 Python Collections (2016, retired 2019) Lists Creating lists

Michael Morale
Michael Morale
2,702 Points

I don't understand what this is asking me.

Can someone clarify this for me?

lists.py
my_list =[ 45, 69, 32]
my_list.append("Necktie") 
my_list.extend
Krishna Desai
Krishna Desai
7,977 Points
  • my_list = [45, 69, 32] creates the list with a couple values.
  • my_list.append("Necktie") will add "Necktie" to index 3 (final position) of my_list
  • my_list.extend is incomplete. However, it should be a method that takes an iterable argument (e.g. string, list, etc.). It will add the elements of the iterable argument to the end of my_list

3 Answers

Steven Parker
Steven Parker
229,005 Points

You're partway there. The challenge wants you to create a list that has "3 numbers and 2 strings" in it, plus "another list with 2 items in it".

So you have the first 3 items, and one string. But you still need another string and the sub-list of 2 items. As Krishna pointed out, that last line is incomplete; but you won't need "extend" anyway. That's for when you want to merge the items from another list, but in this case you want to add the additional list as an item in itself.

Michael Morale
Michael Morale
2,702 Points

This is what I tried: my_list =[ 45, 69, 32,"Klatuu Barrada", "Boomstick"] my_list.append("Necktie") my_list + (["Noodles", "Nickto"])

It's now saying that the number of strings or numbers in "my_list" is not 6.

Steven Parker
Steven Parker
229,005 Points

You only needed one more string but you added two.

And a plain + doesn't change the list, perhaps you meant to use "append" there?

Michael Morale
Michael Morale
2,702 Points

I finally got it. This is what I did. my_list =[ 45, 69, 32,"Klatuu Barrada", "Boomstick"] my_list_better = ["Necktie", "Nikto"] my_list.append(my_list_better)

Steven Parker
Steven Parker
229,005 Points

Michael Morale — Good job! You can mark a question solved by choosing a "best answer".
And happy coding!