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 trialNivesh Sharma
Courses Plus Student 1,941 PointsHow do you move from one item to other in the Multidimensional list.
Tell me What i am doing wrong?
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 member,name in musical_groups:
print(member, name)
1 Answer
Timothy Long
Front End Web Development Techdegree Student 6,833 PointsThis may not be the most clean way, if someone knows a better way please add your comments.
When accessing parts of a multi-demensional list you can call by indexes like with a normal list. For example... if I have this list: things = [[1, 2, 3, 4], ['a', 'b', 'c', 'd']]
I can access the letter 'a' like this: `things[1][0]'.
That being said if you want to move an item from one list to another you could do something like:
things[1].append(things[0][0])
things[0].remove(things[0][0])
That example would add 1 from the first list, and append it to the second one. Then the second line of code would remove the 1 from the first list.
The end result when calling my things
list would be:
[[2, 3, 4], ['a', 'b', 'c', 'd', 1]]
I hope this was helpful!