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

i dont understand what am doing wrong please help ,multidimensional lists task 2 of 2

i keep getting AssertionError

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"],
]
for group in musical_groups:
    print(", ".join(group))
    if len(group) == 3:
        print(", ".join(group))

2 Answers

You're getting the error because your code is generating output that's not expected in the answer.

The second line of code is the culprit, since it's printing out each group as it loops through the list and, if that group is a trio, it's printed out again by your conditional statement.

Try removing the second line and see if that helps.

SERVICIOS ADQUIRIDOS SA DE CV
SERVICIOS ADQUIRIDOS SA DE CV
1,519 Points

The problem is that in the loop the fist thing to happen is the printing of ALL of the groups and then you add the "if" condition.

In order for this to work you need to first stablish the "if" condition telling the code to only work with the groups with the len(3) or trios, because if you join it into a string and then use len() it will count the caracters and not the objects in a list.

The solution is the following:

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

I wish this helps!!