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

Why is this code not working?

I have tried this code in Visual Studio Code and it's working fine.

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))

for group in musical_groups:
    if len(group) == 3:
        print(", ".join(group))

It is not working in the editor of treehouse so now I can't finish the challenge.

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 145,624 Points

Hey there,

You do have it!

However, this is just one of those cases where the 'normal' rules for challenges need to be ignored. Normally each task's code would be added to the previous task, but that is not the case here.
The instructions for the second task are a bit ambiguous when it come to this, but they do actually mean to alter the code from task one to output what is wanted for task two.

Here you have the correct code needed, so if you just completely delete the first for loop and leave the second for the second task, it will pass.

Either task, there should only be one loop coded.

Nice work!! :) :dizzy:

tagging Craig Dennis to have a look to see if instructions could be clarified. :)

Hi Jason,

Thank you for clarifying!

I think it's a good idea to clarify the question a bit. :)