+ 3
out of the code
why is the output of this code 8? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) and what does it mean when there are two lists to be printed like that?
2 Answers
+ 3
The elements of list have a position that begin with 0
list[4] is 5 because is the value in position 4 ( REMEMBER: begin to count from position 0)
list[list[4]] then is the same that list[5] as we say above
and list[5] is 8 replacing it's value
then the sentence print the number 8
you have list inside a list but really are only numbers đ
+ 2
print(list[list[4]])
list[4] is 5
then the print expression is print(list[5]) which prints the number 8