Loops
Loops let you repeat a block of code multiple times without writing it out again and again. This is essential in data science, where you'll frequently need to process every row of a dataset or repeat a calculation until a condition is met.
The for Loop
A for loop iterates over a sequence, such as a list, string, or range of numbers.
scores = [72, 85, 90, 66]
for score in scores:
print(score)
The while Loop
A while loop continues to run as long as its condition remains true.
count = 0
while count < 5:
print(count)
count += 1
Coming Up
With loops covered, the final topic in this section looks at command line arguments, which let you pass input into a Python script directly from the terminal.