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 trialGrayden Kellogg
Python Development Techdegree Student 1,826 PointsPrinting lists that have 3 objects from a multidimensional list.
My output is showing the desired result but I am getting an error that I don't understand.
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:
musical_groups2 = ", ".join(groups)
if len(groups) == 3:
print(groups)
4 Answers
Steven Parker
231,172 PointsThe selection logic is fine. But I'm guessing you intended to print out the formatted version of the list (musical_groups2) instead of the raw list (groups).
MICHAEL WANSLEY
1,229 PointsI'm not sure why I can pass the first part of the challenge but not the trio section, even though the second for loop prints the correct group names.
```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"], ]
s = ", " band = []
for groups in musical_groups: band = s.join(groups) print(band)
for i in musical_groups: if len(i) == 3: print(str(i) + " are part of a trio.")
Steven Parker
231,172 PointsThis is one of the rare occasions where the instructions tell you to modify the code from the previous step. So after task 2, there should still be only one loop.
And for future issues, always start a new question instead of asking one in an "answer". That will give you a better chance to be seen by more students and get a rapid reply.
MICHAEL WANSLEY
1,229 PointsThis is the error message I get. There doesn't seem to be an easy way to upload a screen shot...
"Bummer: AssertionError: 'Ad Rock, MCA, Mike D.' not found in "['Ad Rock', 'MCA', 'Mike D.']\n['Salt', 'Peppa', 'Spinderella']\n['Run', 'DMC', 'Jam Master Jay']" : Hmmm...I'm not getting the output I expected."
MICHAEL WANSLEY
1,229 PointsAH HAAAAAA!!! The answer is, print the value of the .join()!!!! It'd be nice if the req was a bit more informative. But that's just my 'manual tester mind' bitchin about documentation again, LOL!!!!
Grayden Kellogg
Python Development Techdegree Student 1,826 PointsGrayden Kellogg
Python Development Techdegree Student 1,826 PointsI'm supposed to print only trios. Groups of 3 members.