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!

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 Build an Application Multidimensional Musical Groups

james mchugh
james mchugh
6,234 Points

I'm unable to pull specific data from the list.

I've reviewed the videos in this section and I cannot find anything on pulling specific data from the list. It shows us how to access the list. I'm not seeing how to pull the trios from a list also in another challenge it wants me to pull all the continents stating with the letter A. There is not a video on how to access specific data type. Where can I find a video on this?

musical_groups = [
    ["Ad Rock", "MCA", "Mike D."],
    ["John Lennon", "Paul McCartney", "Ringo Starr", "George Harrison"],
    ["Salt", "Peppa", "Spinderella"],
    ["Rivers Cuomo", "Patrick Wilson", "Brian Bell", "Scott Shriner"],
    ["Chuck D.", "Flavor Flav", "Professor Griff", "Khari Winn", "DJ Lord"],
    ["Axl Rose", "Slash", "Duff McKagan", "Steven Adler"],
    ["Run", "DMC", "Jam Master Jay"],
# Your code here
for members in musical_groups:
    print(", ".join(members))

    trios members == 3

1 Answer

Greg Kaleka
Greg Kaleka
39,020 Points

Hi James,

Let's think this through.

We're looping through a list of lists. Each time through the loop, members is the list.

We're being asked to only print the list of members if they are a trio. That means we need to add a condition before we print. What's the condition? If the number of items in the list is 3.

So in pseudo-code:

for each musical group in musical_groups:
    if the number of members in the group is 3:
        print the group's names

Make sense? How can you turn that into real Python code? You'll need to use a function that counts the length of the list.

Let us know how you make out.

Cheers :beers: