+ 2

Can anyone please explain print(list[list[4]]) if there is list=(1,3,5,7,8,11,4)

10th Mar 2017, 4:40 AM
Dipankar Choudhury
Dipankar Choudhury - avatar
4 Respuestas
0
1) list[0] = 1; list[1] = 3; list[2] = 5; list[3] = 7; list[4] = 8; list[5] = 11; list[6] = 4. 2) look at inner expression, list[4]. Ok, it's 8. 3) list[4] ->8; list[list[4]] = list[8], list doesn't have value with index of 8, exception output..
10th Mar 2017, 4:57 AM
Tony Loa
Tony  Loa - avatar
0
Thank u for explaining me. Then the control structures module 2 question no.1 asking me wrong question. And output should be error i suppose.
10th Mar 2017, 5:03 AM
Dipankar Choudhury
Dipankar Choudhury - avatar
0
I'm looking at similar question in module2 quiz and there different list, [1,1,2,3,5,8,13] and list[list[4]] is 8, my answer is correct.
10th Mar 2017, 5:09 AM
Tony Loa
Tony  Loa - avatar
0
Ok thank u for ur help 😊
10th Mar 2017, 5:12 AM
Dipankar Choudhury
Dipankar Choudhury - avatar