I was wondering in CODE CHALLENGE: LOOPS, Divisible by Ten, how i get the numbers that are divisible by 10 in a list?

def divisible_by_ten(nums):
  for i in range(nums):
    if i % 10 == 0:
      return i

print(divisible_by_ten([20, 25, 30, 35, 40]))

so i want the output 20, 30, 40

I can´t see through what my mistake is

The challenge is to return the number of elements in the list that are divisible by 10, so if you set up a counter and then replace the return statement in your loop with a statement that increases the counter by 1 each time, you’ll be almost there.

1 Like