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

How do you print only the lists that contain 3 items in a multidimentional list?

How do you only print the lists that contain 3 items in a multidimentional list. This is the list:

groups.py
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

2 Answers

Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

You're for sure going to want to incorporate the len function which counts the number of items in the argument passed. I would probably do this with an if statement that once satisfied. After peeping at some of the other answers to this question it jogged my memory that you also need to use the join function.

'conjoining string'.join(arg) len(arg) list.append(arg)

Comment if you need additional hints

The problem with that is that I don't know how to use it in this case, because in eny way I use it I get an error

Andy McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Andy McDonald
Python Development Techdegree Graduate 13,801 Points

You mean the join method? So first it wants all the group members like so: 'YG, 2chainz, G-Easy' this is all one string. The "joining string" will be the value between each object. You would get YG2ChainzG-Easy without the ", " between them. So you would use the method like ", ".join(arg).

*Spoiler alert*

The "arg" your passing in is the iteration in the for loop. for x in musical_groups: ", ".join(x)

This particular challenge is not super clear on what it wants the output to be but I passed it like so:

for x in musical_groups: var = ", ".join(x) print(var)