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!
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
I'm not sure how to print only the groups with 3 members.
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 item in musical_groups: if len(musical_groups) == 3: print(", ".join(item))
Rohald van MerodeTreehouse Staff
Hey fionaj 👋
You're super close to the solution here! There's only one thing that stops your code from working and that is the conditional that you've created.
Currently, you're checking the length of the
musical_groups list which is 7 (all nested lists in musical_groups)
Instead you'll want to check the length of the
item which represents a single group in your loop 🙂
for item in musical_groups: if len(item) == 3: print(", ".join(item))
Hope this helps!
Robbie Baker1,806 Points
The key here is just to remember items as objects inside the list. These can be other lists, strings, ints, etc.