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 can't understand this error

Can somebody help me fix this code? I don't understand what is wrong with it

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 x in musical_groups:
    print(", ".join(musical_groups(x)))
    x = x + 1 

1 Answer

diogorferreira
diogorferreira
19,363 Points

Hi, when you are looping through the musical_groups x will be set to each individual list inside that list so in the first iteration it would equal to: ["Ad Rock", "MCA", "Mike D."] and so on...

  • The for loop wouldn't need to increment by 1 to move into the next iteration - it does it by itself, and that would result in an error because you're trying to do x = ["Ad Rock", "MCA", "Mike D."] + 1 A list cannot be concatenated to an integer
  • Last thing, you can't call musical_groups(x) in .join() its a list not a function, to solve this you can just pass in x to join()

Here's how your code could look:

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