What is the output of this code? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]]) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the output of this code? list = [1, 1, 2, 3, 5, 8, 13] print(list[list[4]])

Why is the output 8?

9th Apr 2018, 7:21 AM
VISHWA PRIYA M
VISHWA PRIYA M - avatar
3 Answers
+ 11
the answer is 8 because what it does is it takes the 4th index of list which when you fill into the code is print (list[5]) which is 8
9th Apr 2018, 7:25 AM
Obbu
Obbu - avatar
+ 7
lixst = [1, 1, 2, 3, 5, 8, 13] ''' print(list[list[4]]) , do it separately, 1st ''' print(list[4]) # output is 5 print (list[5]) ''' 2nd part output is 8 '''
9th Apr 2018, 7:37 AM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
0
list = [1, 1, 2, 3, 5, 8, 13] ''' print(list[list[4]]) , do it separately, 1st ''' Ie, solve one by one print(list[4]) # output is 5 print (list[5]) ''' 2nd part output is 8 '''
25th Apr 2020, 10:30 AM
Shivam jaiswal