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


#1



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:

vs

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!


#2

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


#3

That makes sense, thank you!


#4

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