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

Musical Groups: Multi Dimensional Arrays in Python Lists

Hi All--

Arrays are about my least favorite thing in coding and I am having a hard time with this one.

I am not sure where I have gone wrong.

I am getting an AssertionError which is referencing printing and newlines, so not sure where I goofed up.

I have already rewatched the multidimensional array video again a couple of times without any luck.

Thanks!

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:
    group.join(", ")
    group += 1

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Teamz,

Your for-loop declaration is correct but once inside the loop you are making a couple of mistakes:
Firstly, join() in Python works differently (backward even) from what you might expect, especially if you've seen similar constructs in other languages. join() is a method on a string NOT a method on a list. This means that you apply join() TO ", " and then pass the list in to join as its argument.

This will give you a string, comprising the comma-separated band members. But you still need to do something with this string. The assertion error is giving you a clue what you should be doing with the string (hint: it rhymes with 'hint'...)

Lastly, you are incrementing group, which is invalid syntax (group is a list not an integer, so you can't add 1 to it), but even if it weren't syntactically wrong, it would be logically wrong. The for-in loop construct automatically moves to the next item in the list, you don't manually increment the loop index.

Hope that clears everything up

Cheers

Alex