number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2]) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2])

print(things [2][2]) what does the second [2] indicate?

10th Aug 2021, 6:55 AM
Dipanjan Basu
Dipanjan Basu - avatar
2 Answers
+ 5
The element at things[2] is a list. things[2][2] indexes the 3rd element of this list in the things-list
10th Aug 2021, 7:05 AM
Lisa
Lisa - avatar
+ 1
Say that the list things is [[1, 2], [3, 4]] for an example. To access things[1] would return [3, 4], because [3, 4] is the second element in the list, even though it is a list itself. Accessing things[1][1] would return 4, because [1][1] basically means the 1st index of the 1st index in things. Hope this helps, if it still doesn't make sense, let me know!
10th Aug 2021, 7:55 PM
Chloe
Chloe - avatar