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

I don't understand the problem in Challenge Task 1 of 1 in the Collections section. creating lists

The question asks to create a list (my_list). Put 3 numbers and 2 strings into it in whatever order. Then the last item should contain a list of 2 items in it. There are 6 objects total.(or so the error message keeps telling me).

This makes absolutely no sense.

3 Answers

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,077 Points

Alright, so for starters, you are definitely overthinking this problem. Secondly, if you do not have enough string objects, then you are either not closing a string somewhere, or you aren't adding 2 strings. Thirdly, it is asking you to add a list inside another list. The fact that you think you need to use .extend tells me you may not actually be using it properly. .extend() joins to lists together and creates 1 new list which is the combined list. Not a list within a list.

Instead of going back and watching videos I recommend you just watch this specific section, since it will cover lists in detail. You seem to be trying to use knowledge you learned either outside of Treehouse or from a different set of videos. Unfortunately, you aren't using them properly.

As for the solution:

my_list = [1, 2, 3, "a", "b", ["item1", 100]]

That's it. You were definitely overthinking it. In the future, if you are stuck on a challenge instead of overthinking it, step back and just make sure you completely understand what it is asking you to do. If you find yourself using methods, classes, loops, etc. that you haven't learned about in the current series, you are probably overthinking it.

As for a function to join 2 lists together, in the way that this question wants it. You would need to use .append(). Fortunately this question didn't need any methods to solve though.

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,077 Points

Ok, so I think you may just be overthinking this challenge, all you really need to do is just create a simple list with 6 items in it.

Two of those items need to be strings: "Hello", "words", etc

Three of those items need to numbers: 1, 4.76, -9, etc

The last one needs to be a list itself that just contains 2 items in it (just use either numbers, strings or both).

I am going to assume that you at least know the syntax for a list, if you don't I advise re-watching the videos covering lists.

If you still need help, let me know and I will give you the solution, but then you should go back and re-watch the videos.

I created said list and it kept saying not enough string objects. I know how to write the lists, but it's saying it's wrong. It's asking for a list inside a list, which would use .extend to join two lists together.