0
print(list[list[4]]) question
What is the output? list=[1,1,2,3,5,8,13] print(list[list[4]]) Solution: 8 The notes say index 4 becomes number 5. Which becomes number 8 (our solution). Why? How was I supposed to know to substitute index number 4 (no instructions were given)? Thanks for any help.
4 Answers
+ 2
Thanks Bishu Giri:). I just ran the code in playground and I can see what you mean. The command is "print" and the code itself was saying like "First print nested index number 4 (which is five) now print whatever number is indexed at 5". So print is the command and I was just missreading the code.
Thanks again for your concise explanationđđ»
0
Thanks for that, The Trump.
So list here is a command? I thought it was just telling me what type of data it was.
0
There are few keywords that are internal & python uses it for specific purposes, avoid using the same name as a variable. when you type this keywords it will come as green which means it is a python keyword.
Here, list is ideally a function that creates object of type list. for figuring out the data type use "type" function