Skip to content

Latest commit

 

History

History
 
 

12 - Loops

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Loops

For loops

For loops takes each item in an array or collection in order, and assigns it to the variable you define.

names = ['Christopher', 'Susan']
for name in names:
    print(name)

While loops

While loops perform an operation as long as a condition is true.

names = ['Christopher', 'Susan']
index = 0
while index < len(names):
    name = names[index]
    print(name)
    index = index + 1