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

Balazs Ferencz
Balazs Ferencz
4,993 Points

What is the solution please?

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: members = ", ".join(members) i = 0 num = len(members) if i < num: print (musical_groups[i]) i += 1

Was meant to print only groups with 3 members...

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
for members in musical_groups:
    members = ", ".join(members)
    print(members)

3 Answers

Hi,

Try an if statement, in the for loop, with: if len in equal or greater than 3. If true run the join, else continue.

But let me know if you need further assist.

Balazs Ferencz
Balazs Ferencz
4,993 Points

Hi thanks for the help... :)

for members in musical_groups: # comment line # if len(members) == 3: print(members)

This does exactly what the challenge asks for yet the challenge gives me an error saying I'm not joining the lists.

If I put the line to .join the lists where I say #comment line the whole code does not work. Why? Also is my answer wrong or is the challenge funny? As in an offline editor the code works as intended...:)

Did you indent after the if check? that might be a problem.

And take out the print statement. The checker bot does not like calling or print statements in the code. I also struggled with that.

Have the join in the if as you had it. Just remove the print.

Let me know if you need anything else.

Balazs Ferencz
Balazs Ferencz
4,993 Points

Figured it out finally thanks for the help, it was a matter of swapping the order of lines...:)

Thanks a lot again...:)

have fun