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 trialAlex Franklin
12,403 PointsAt 00:07:30:00, you say index "one - zero" returns "Respect," but isn't that TEN? Should it be, "ZERO/ONE" instead?
I'm super confused if this IS NOT a simple case where the presenter mis-spoke... You say the index value, [10], will return Aretha Franklin's, "R.E.S.P.E.C.T.." However, shouldn't it be the opposite?
I CANT FIGURE OUT HOW TO MARK BEST ANSWER AND CLOSE THIS, BUT THANK YOU DAVE THAT MAKES MUCH MORE SENSE AND I HAVE A BETTER UNDERSTANDING NOW:)
1 Answer
Dave StSomeWhere
19,870 PointsSince it is a multi-dimensional (two) array, he is referring to two different indexes. Index 1 of the first array points to the second song and Index 0 of the inside array points to the song title. Two different sets of square braces.
two_dimension_array = [
['I did it my way', 'Frank Old Blue Eyes'],
['R.E.S.P.E.C.T', 'The Queen of Soul, Aretha'],
['Born to Run', 'The Boss, Bruce'],
['Imagine', 'John Lennon']
]
print("Index 1, 0 is --> " + two_dimension_array[1][0])
print("Index 0, 1 is --> " + two_dimension_array[0][1])
# outputs:
Index 1, 0 is --> R.E.S.P.E.C.T
Index 0, 1 is --> Frank Old Blue Eyes