6) Loops

For loops are very important in Python, they allow code to repeat for a certain amount of time. Here is an example of a code running for a certain amount of time.

For loops can be used to print each item in a list
Here, instead of printing an array, the For loop below will print out each color individually.

For loops can also be used in dictionaries:

While Loops are also important. They repeat code until a certain condition is True.

While can also be used to compare Boolean values.

Leave a Reply