0 out of 464 challenges solved
Write a Python function `first_odd(nums)` that takes a list of integers `nums` as input and returns the first odd number in the list. If there are no odd numbers, the function should return `-1`. #### Example Usage ```python [main.nopy] print(first_odd([2, 4, 6, 8, 9])) # Output: 9 print(first_odd([2, 4, 6, 8])) # Output: -1 print(first_odd([1, 2, 3, 4])) # Output: 1 ``` #### Constraints - The input list can be empty, in which case the function should return `-1`. - The input list will only contain integers.
def first_odd(nums):
"""
Find the first odd number in the list.
Args:
nums (list): A list of integers.
Returns:
int: The first odd number in the list, or -1 if no odd number exists.
"""
# Your code here
pass