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 trialZinar Qasim
1,331 PointsHow can I solve this challenge?
I need to print out the Trios out of these... I tried everything, googled it, searched on many websites, reviewed the videos I watched previously, I couldn't find anything that would help me I don't know I'm just lost, I just need an answer in code... not text.. Thank you!
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
Z = ", "
for group in musical_groups:
print (Z.join(group))
print (group [0][2][6])
Michael Hulet
47,913 PointsWithout the print
statement on the last line, your code passes task 1 just fine. Are you still having trouble after removing that?
Zinar Qasim
1,331 PointsIām on task 2, (print trios out)
ā
1 Answer
Michael Hulet
47,913 PointsTask 2 of this challenge asks you to only print out a group if it has 3 members. You'll know a particular group has 3 members because the list of members will have 3 items in it. To pass task 2, you can use the len
function to check how many items are in the list you're inspecting, and if it has 3, you print out exactly what you did before. However, you only want to print something if a particular group has 3 members in it
Zinar Qasim
1,331 PointsYess! I got it! ------ if len(group) == 3:
Thank you very much for the hint!
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsHello Zinar,
Which task are you on?