+ 2
What is the code out put Sp=[[4,1],[5,2],[6,3],[7,4]] Print(sp[1][1][0])
kindly explain how to go about this
7 odpowiedzi
+ 3
sp=[[[4,1],[5,2]],[[6,3],[7,4]]]
This should do the trick if you want 7.
+ 2
That will just give you an error. Either add some parentheses or remove [0].
+ 1
It will output an error, coz that's not how you handle a list...
If you want, you might be confusing this with print(sp[1:1:0])
Which is the correct way to handle a list
+ 1
@mevin there should be no 3rd argument, in that case.
What you are doing is a "list of lists". The first argument is the index of the list you chose, the second is the index of the inner list. There is no need for a third argument.
0
actually this is a stacked list. Nothing to do with slicing a list. i know if you run the code with print(sp[1][1]) it will print out 2. so my question is what does the 3rd argument [0] mean
0
@tobi the answer according to solo learn is 7 where do I add the parenthesis
0
@tobi thank you very much... just reported the question as a wrong answer. I appreciate your time.