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

My code wont pass test, but works fine in PyCharm. How do I progress in the course?

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

for groups in musical_groups: if len(groups) == 3: print(', '.join(groups))

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

for groups in musical_groups:
    if len(groups) == 3:
        print(', '.join(groups))

3 Answers

Gabriel Plackey
Gabriel Plackey
11,064 Points

You need to rermove your first loop. I believe you are supposed to expand on the first loop to complete the second challenge, not write another. Because you have both, it is running both, and printing non trios. That is what's making you fail the challenge.

That did it! I knew I had it right. Ok but you guys should be more accurate in what the request for the test is...how am I supposed to know I need to remove all code BUT the one concerning the specific question being asked when working on the same code?

Gabriel Plackey
Gabriel Plackey
11,064 Points

If I recall correctly, it will specifically tell you to write another loop or function or whatever it is. If it does not, I would expand on what you currently have.

I bumped into a similar issue with another Challenge. It was asking me to use the insert method to place "start" at the beginning of a list. I put "Start" (capital S)

list.extend(0,"Start")

instead of... list.extend(0,"start")

and it wont pass the code. I guess I have to really REALLY read the instructions and be careful what they say exactly.