+ 1
Unexplained python command
There is a question in the module 2 quiz where it gives you the command print(list[list[4]) and it isn't exlained, I have literally read all of module 2 and couldn't find anything like that, can someone explain it to me?
1 Odpowiedź
+ 3
Here:
list[1,1,2,3,5,8,13]
print(list[list[4]])
The compiler will first execute list[4](it will return the element in index 4) and then return the value of list[4] as an index for list[].
the return value from list[4] is 5 when you put it as an index for the list it will return the element in index 5. so it will print 8.