0

I want to write a function which takes a list of numbers and returns another list with elements divisible by 5. However, I keep getting the error 'nlist is not defined' and I dont know where am I making a mistake.

this is the function that I wrote:

def divisible_by_five(numbers):
    nlist = []
    for i in range(0, len(numbers)):
        if numbers[i] % 5 == 0:
            nlist.append(numbers[i])
print('your list is: ', nlist)


f = [1,2,3,4,5,55,65,75]
divisible_by_five(f)
Mahan
  • 1
  • 1
  • your function should likely `return nlist`. Then you would use `out = divisible_by_five(f) ; print('your list is: ', out)` – mozway Jun 10 '23 at 09:30

0 Answers0