+ 1

Python list

I have a little trouble understanding this part. list = [ 1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) Answer is 8: How do we arrive at 8👀

15th Apr 2019, 3:16 PM
washie mugo
washie mugo - avatar
5 ответов
+ 6
Indexes are from 0 so list[4] evaluate to 5 so you get list[5]. Index 5 is 8. (as index 0 is 1 in your list, index 1 is 1, index 2 is 2, index 3 is 3, index 4 is 5 and index 5 is 8).
15th Apr 2019, 3:25 PM
Hubert Dudek
Hubert Dudek - avatar
+ 3
It's 8, because list [4] = 5, next evaluation is list [5] which is 8. Hope it helps you.
15th Apr 2019, 3:24 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
Oo, yeah i see now😁😁. Thanks guys . I feel stupid. Appreciate the help
15th Apr 2019, 3:27 PM
washie mugo
washie mugo - avatar
+ 1
washie mugo , you are welcome 😉
15th Apr 2019, 3:29 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
This is one of the worst ways to iterate a list, I am not sure why SoloLearn puts these out there as they make no sense and don't really teach. Just my opinion
9th May 2019, 7:40 PM
Brian Petry
Brian Petry - avatar