list=[1,1,2,3,4,5,6,7] print(list[list[4]]) | SoloLearn: Learn to code for FREE!

+1

list=[1,1,2,3,4,5,6,7] print(list[list[4]])

Output along with explanation please 🙏

6/19/2020 11:03:44 AM

Saumitra

6 Answers

New Answer

+5

Saumitra Note : Try to avoid using data types as identifiers Mistake: you have not closed print bracket Here's my explanation 👇 list=[1,1,2,3,4,5,6,7] 👇👇👇👇👇👇 print(list[list[4]]) print(list[4]) print(4) Output : 4 list[4] means you are calling the 5th element from the list as indexing starts from 0 & here 5th element is called 2 times because list[4] = 4 I hope you understood 🙂

+1

Try answering these questions. 1. What is list[4]? 2. Which type is list[4]? 3. Can I put complex expressions inside array indexing? Once answered, you may gain some more insight of what follows.

+1

Saumitra Yeah it's correct list=[1,1,2,3,5,8,13] 👇👇👇👇👇👇 print(list[list[4]]) print(list[5]) print(8) Output : 8 list[4] means you are calling the 5th element from the list as indexing starts from 0 So, list[4]=5 Now again list[5] means you are calling the 6th element from the list as indexing starts from 0 So , list[6] = 8 I hope you understood 🙂

+1

yes now i understood...thanks a lot 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 🙂🙂🙂🙂

0

Saumitra Save your code in code playground and share it here

0

list=[1,1,2,3,5,8,13] print(list[list[4]]) i got 8 as an output here...why not 5???