+ 1
how and why does list[list[4]] work in quiz 2? I don't get it and it isnt explained??
2 ответов
+ 2
I try to explain it with an example:
my_list = [3,1,5,2,7].
You can call each item in the list by its index. The fist index number is 0. Use the list name and the index of the element you want to call:
my_list [0] = 3
my_list [1] = 1
my_list [2] = 5
etc.
my_list [my_list [3]] = my_list [2] = 5.
I hope you can solve the quiz now by yourself.
+ 1
thanks. now I get it. it's actually using the number in the location of list[4] as the location of the output :D