0
What does this part "(n[m])" in the code below?
https://code.sololearn.com/cufhBUrO6558/?ref=app I played with the numbers in the hope I could find it out myself, but I still have no idea. Thanks in advance
3 Réponses
+ 1
It accesses the m-th entry of array of array n. The indices start from 0.
n=[23,1,2,3]
n[0] = 23 # first entry of n at position 0
n[1] = 1
n[2] = 2
n[3] = 3 # last position, since the array has 4 entries and the indices 0-3 cover them all
Another example:
x = 3
arr = [7,3,36,87,1,9]
print(arr[x]) # output: 87
+ 1
Woehoe! Thanks Supriya and Matthias! Now it's clear for me! 💡🤔 💡⚡. 😊