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 trialMichael Morale
2,702 PointsI don't understand what this is asking me.
Can someone clarify this for me?
my_list =[ 45, 69, 32]
my_list.append("Necktie")
my_list.extend
3 Answers
Steven Parker
231,269 PointsYou'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
2,702 PointsThis 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
231,269 PointsYou 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
2,702 PointsI 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
231,269 PointsMichael Morale — Good job! You can mark a question solved by choosing a "best answer".
And happy coding!
Krishna Desai
7,977 PointsKrishna Desai
7,977 Pointsmy_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_listmy_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