Difference between for i in list and for i in range(len(list))


Hi there! I'm just about to finish 15. Practice Makes perfect, and I find myself having some troubles understanding the difference between:

for i in list:


for i in range(len(list)):

Could someone be so kind to outline what each of the lines of code do and when to use them, or point me to a resource that I can read up on?

Thank you!


i will give you the values from the list, range() will give you indexes. indexes can be used to manipulate the list


That makes sense, thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.