for/loop counters, When I’m shown a flow diagram it makes sense but I can’t seem to visualize the diagram from just looking at all the i’s

Anyone have a link to a video that breaks this down for a dummy like me?

Reply to this note

Please Login to reply.

Discussion

Not sure what you need but here’s an diagram image, maybe it will help. Forgot the ‘i’ in noting ‘i < ‘ on the function. It’s technically identical logic for while just different syntax and implementation.

my_list_to_look_through = [2,7,1,9]

number_items_in_list_counter = 0

for x in my_list_to_look_through:

number_items_in_list_counter +=1

Every time the loop occurs it will iterate over the list to the next item. "x" can be any variable i, j,k, younginter, it's just a place holder. every time the loop executes it will add 1 to the number_items_in_list_counter. In this case it will equal 4.

Another example:

my_list_to_look_through = [2,7,1,9]

empty_container = [ ]

for x in my_list_to_look_through:

empty_container.append(x)

This will take the first item out of my_list_to_look_through and add it into the empty_container list. It will go through the loop, append 2 to empty_container, then 7, then 1, then 9.

Now

Previously defined

my_list_to_look_through = [2,7,1,9]

And our new container has the same

empty_container = [2,7,1,9]

that makes sense… btw your zap button doesn’t exist