Python Introducing Lists Build an Application Multidimensional Musical Groups

Ryan McGuire
Ryan McGuire
3,754 Points

I do not feel this was previously covered to this extent. I checked online, but none of the responses seem to be clear.

Can someone please explain or point me to the video that would beset cover this? I understand I need to join it and possibly use a for loop, but cannot find an example. I am just guessing

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
    s = ','.join(musical_groups)

1 Answer

Alex Koumparos
Alex Koumparos
Python Web Development Techdegree Student 33,845 Points

Hi Ryan,

Looking at your code, I think you know all the things we need to pass this challenge. Let's start by fixing a couple of typos then we can work through the code and the error messages we get to zero in on the correct solution.

Your first typo is that you omitted the : at the end of your for statement. That's going to give you a syntax error. Your next typo is your string: you've got ',' (just a comma) but the challenge is asking:

... together with a ", " comma space as a separator ...

So we need to change ',' to ', '.

The last typo is that you've pointed the join method at the wrong variable. Remember that you are looping through musical_groups and each time putting the element in the variable group. The implication is that inside your for loop you want to do something with group not with musical_groups. Yet your join is joining the elements of musical_group.

The other thing we probably want to keep in mind as we tweak the code is that you've assigned the result of your join to a variable "s" but you've not done anything with it. The challenge question is not as clear as it should be about what exactly it means by "output" but we're going to need to do something with "s" to get an output of some sort.

Here's what your code looks like with the fixes we've come up with:

for group in musical_groups:
    s = ', '.join(group)

Now let's look at what we get from the test runner:

AssertionError: 'print' not found in 'musical_groups = [\n    ["Ad Rock", "MCA", "Mike D."],\n 
...
Remember to print out the joined string of artists

Ok, that tells us what the challenge means by "output". Note that it is looking for us to print the output.

Let's add a print statement:

for group in musical_groups:
    s = ', '.join(musical_groups)
    print(s)

And we're done!

Hope that helps,

Alex