list | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

list

number = 3 things = ["string", 0, [1, 2, number], 4.56] print(things[1]) print(things[2]) print(things[2][2]) How does this last code works?

16th Apr 2020, 7:58 AM
PRIYANKA K
PRIYANKA K - avatar
2 Answers
+ 2
things[2] = [1,2,number] so things[2][2] = [1,2,number][2] = number = 3
16th Apr 2020, 8:04 AM
John Robotane
John Robotane - avatar
+ 1
things is a list and has a list in it at index 2. The element at index 2 of this list in things is indexed in the last line of your code
16th Apr 2020, 8:03 AM
Lisa
Lisa - avatar