Iterators with for loops - mrprov12/DSPrep GitHub Wiki
iteration with for loops
initialize a variable to be accumulated, then in a for/while loop accumulate as you iterate through
for char in string:
#iterates through every character in string
for word in phrase:
#iterates through every word in sentence as separated by whitespace chars
for num in range(0, 100):
#iterates through nums 0-99
for i in range(len(list)):
#iterated through indexes of list from 0 to len(list)
for elem in list:
#iterates through all elements of list
for i, elem in enumerate(list):
iterates through both i and elem in list
for a,b,c in zip(list_1, list_2, range(len(list_3))):
#iterates through parallel lists at same time