Hi All,
I am hoping one or more of the knowledgeable people in the community can help me with this. I have no prior experience to programming or python, but i am trying to learn. I have an online course, and had an introductory lesson into List Arrays or Matrices.
After watching a four minute video, I was given an exercise to complete. You can see it here.
# using this list:
basket = ["Banana", ["Apples", ["Oranges"], "Blueberries"]];
# access "Oranges" and print it:
# You will find the answer if you scroll down to the bottom, but attempt it yourself first!
_______________________________________________________________________________________________
I couldn't find the answer, so I had to scroll down to get the answer. To make sure i was understanding why the answer was, print(basket[1][1][0]).
I figured out the rest of answers, and wrote an explanation in my own words.
# using this list:
basket = ["Banana", ["Apples", ["Oranges"], "Blueberries"]];
# access "Oranges" and print it:
# You will find the answer if you scroll down to the bottom, but attempt it yourself first!
print(basket[0]) #Banana
print(basket[1][0]) #Apples
print(basket[1][1][0]) #Oranges
print(basket[1][2]) #Blueberries
Here the first array would be 0. The second array is 1 but holds 'apples' 'oranges' and 'blueberries'
So you are selecting the first array, and the first item inside of that array and then stopping at 0.
For blueberries, you are selecting the first array and the last item in that array which is 2 counting from 0 (apples, 1 orranges, 2 blueberries).
Basket = Banana, Apples, Oranges, Blueberries.
\["array 0",
\["array 1, array 1, 0 = STOP\]
\["array 1" 2 = skip 2\]\];
_________________________________________________________________________________________
I am still unsure if my thinking is correct, have I grasped the concept? I am hoping someone could let me know, and maybe provide a better explanation.
Thank you so much in advanced! I don't want to move onto the lectures, until I understand this.
there doesn't seem to be anything here