manyspikes

For loops

Initialising environment...

Instructions

In this exercise we will look at how loops can help us process elements in a list.

Define the following variables:

data = [1.3, 1.6, 2.1, 1.1, 1.5, 0.7, 5.9, 0.2, 2] threshold = 2 outliers = []

Using a for loop, iterate over all the elements of a list and if the element is greater or equal than threshold use the append method to add the element to the list outliers.