8. Loops

A computer program can perform repeated tasks using loops. Loop is a powerful coding tool, because it helps us process thousands of data entry quickly and easily.

You can print out a list:

name_list = ["mary","john","paul","eric"]
‚Äč
for name in name_list:
print(name)
for name in name_list:
print("Hello " + name)

You can also loop through specific range of items in a list:

for n in range(1,3):
print("Hello " + name_list[n])

...which is the same as:

print("Hello " + name_list[1])
print("Hello " + name_list[2])
print("Hello " + name_list[3])