i find some parts in the lectures difficult to understand
1 answers ( 0 marked as helpful)
Hi Andrew!
Thanks for reaching out.
The first for loop itterates through every element from the array using the name of the array.
The second for loop uses the range()
method with an argument len(x)
. This means we use range(3)
in this loop. In the print statement we use x[item]
. The item variable is initially 0, then 1 and then 2. So, using x[item]
means x[0]
, x[1]
and x[2]
. To sum up, the first loop iterates through the elements of the array and the second one does the same but with the help of indexing.
Hope this helps.
Best,
Tsvetelin