I tried the following code:
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for x in arr:
if x > 3:
arr.remove(x)
print(arr)
It gives the following output:
[1, 2, 3, 5, 7, 9]
While instead i thought it would remove from the array every element bigger than 3. Why is that? And how can i make it remove every element bigger than a certain amount?