Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Lists Build an Application Multidimensional Musical Groups

Vladimir Lapcevic
Vladimir Lapcevic
6,363 Points

What is wrong with this code?

please help

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 group in musical_groups:
    print(', '.join(group))

    if len(group) == 3:
        print(group) 

2 Answers

Hi Vladimir,

in your code you already print out the result before the conditional statement runs...

But you want to only print it out IF the length of the group is 3.

So you just have to change the order of your code a bit.

Plus you don't need the second print command at the bottom of your code (you actually have two print commands).

Does that help?

PS: You can upvote my post and/or mark as "best answer" (at the bottom of my post) if it helped you. :-)

Drew Conner
Drew Conner
4,027 Points

I think there is a misunderstanding in the phrasing of "Now I'd like to see only groups that are trios, you know 3 members. So can you please only print out the trios? It should still use the joined string format from task 1."

Instead of adding code to only print trios and still print all groups, you need to modify which groups are printed at all, as Nils mentioned.

If the expected output of task 2 is:

Ad Rock, MCA, Mike D.

Salt, Peppa, Spinderella

Run, DMC, Jam Master Jay

Can you think of a way to modify your code to produce that output?