[Solved] How can I return the odd numbers of a list, using only recursion in Python? [closed]


def find_odds(numbers):
  if not numbers:
    return []
  if numbers[0] % 2 == 1:
    return [numbers[0]] + find_odds(numbers[1:])
  return find_odds(numbers[1:])

No extra variables or parameters needed.

7

solved How can I return the odd numbers of a list, using only recursion in Python? [closed]