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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![matthew mahoney](https://uploads.teamtreehouse.com/production/profile-photos/11586855/micro_132030125_10224012420715939_2848807104923404711_n.jpg)
matthew mahoney
Python Development Techdegree Student 2,536 PointsNow I'd like to see only groups that are trios, you know 3 members. So can you please only print out the trios?
Hey there, Having a bit of a struggle with this one. I thoroughly watched the videos and must have missed this concept. Can someone help me get it right and explain what's happening in the right code? Thanks!
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 band in musical_groups:
seperator = ", "
bands = seperator.join(band)
if len(bands) == 3:
print(bands)
2 Answers
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsYou are very close!! If you join the band members into a string before the len()
check, you are checking the length of the string, which is almost certainly not 3 characters.
Post back if you need more help. Good luck!!!
![Peter Vann](https://uploads.teamtreehouse.com/production/profile-photos/8935412/micro_MaiTaiPeteGravatar.jpg)
Peter Vann
36,426 PointsHi Matthew!
Join syntax is a little backwards from how you would do it in, say, Javascript.
This passes task 1:
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 band in musical_groups:
if len(band) == 3: # you want to test the length of each "band list", and only include the ones with 3 members
print( ", ".join(band) )
More info:
https://www.w3schools.com/python/ref_string_join.asp
I hope that helps.
Stay safe and happy coding!