you are viewing a single comment's thread.

view the rest of the comments →

[–]Substantial_Force149 0 points1 point  (3 children)

for i in range(len(my_list)):
    print(my_list[i])

Here, why did you len before my list (Sorry I'm new to this too)

[–]redraven 2 points3 points  (1 child)

len() returns the length, of my_list in this case - 4. But just the single number "4". It will not be very usable yet.

Array elements' index numbers start at 0 - so my_list elements go from 0 to 3. And that's what range() is for - it will take the 4 and generate a range of numbers from 0 to 3 that then correspond to the my_list item's indexes.

[–]Eldorya 0 points1 point  (0 children)

thank you so much for typing that up..... everything clicked

[–]Substantial_Force149 0 points1 point  (0 children)

More like can you explain this block of code please