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 trialVladimir Lapcevic
6,363 PointsWhy my second task is not correct? Please help.
I do not understand why my second task is not correct. Thanks. Please review my code and correct it as it should be.
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:
print(", ".join(group))
for group in musical_groups:
if len(group) == 3:
print(group)
1 Answer
Unsubscribed User
Front End Web Development Techdegree Student 33,900 PointsHi Vladimir,
you did a great job but just a little bit too much... :-)
The first declaration...
for group in musical_groups:
print(", ".join(group))
is correct and great.
But then you start the same loop declaration again - why?
Instead you can just put the conditional statement
if len(group) == 3:
in front of the print declaration of your first correct code.
You dont need a second for loop.
Makes sense?
Happy coding, Nils
PS: You can upvote my post and/or mark as "best answer" (at the bottom of my post) if it helped you. :-)