+ 1
a = ( a [a [a [a [1] - 8 ] ] ] ). I need a little explanation on how we get 5 when executed or print. Thanks
Help solve
4 odpowiedzi
+ 2
Always inner operation(in brackets) gets operated first.. So, a[1] value retrieved form the array and the operation gets performed.. Similarly, after performing operations respective values gets retrieved... Hope you understand 👍
+ 1
Thank you so much sarada lakshmi, I will be glad if you can expanciate more.
This is the question:
a = (6, 4, 4, 5, 7, 3, 10)
Print(a [a [a [a [1] - 8 ] ] ])
I need explanation on how we get 5
+ 1
Yeah!! Surely I'll explain...
In the given tuple, a[1] = 4
So, a[1] - 8 = - 4
Negative indexing needs to be calculated from the last..
So, a[-4] = 5
Now, a[5] = 3
Next a[3] = 5
So,finally you'll get 5 as the result.. If you don't understand, try to take a pen and paper and start solving the same as what I said... Hope you understand 👍
+ 1
This is so explanatory. Thank you so much. Am greatful.