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 trialpratyush raj
7,097 Pointsi am not able to remove the last comma from the newly created string(multidimensional list joining)
ithe question in which we have to take a multidimensional list and make them to join together with a comma in seperation
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
s=''
#to=''
print("musical groups:")
for item in musical_groups:
to=",".join(item)+","
s=s+to
#print(to)
print("here:"+s)
1 Answer
Steven Parker
231,248 PointsIt looks like you're attempting something different from what the instructions are asking for. In particular:
- they want each group printed out separately
- the "print" should be part of the loop
- you won't need a variable ("s") to accumulate multiple groups in
- the separator between member names should be both a comma and a space
pratyush raj
7,097 Pointspratyush raj
7,097 Pointsi tried all the soultions given in treehouse community after frist list comma is not coming now