Why is the output is 8 in the following code? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Why is the output is 8 in the following code?

list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])

11th Dec 2022, 2:01 AM
Haru
Haru - avatar
1 ответ
+ 2
The number at index 4 of the list is 5. Therefore, when we use this number as an index to access an element of the list, we get the element at index 5, which is 8.
11th Dec 2022, 2:36 AM
Calviղ
Calviղ - avatar