Take n elements into an array and print the odd numbers and even numbers

Constraints:
0 <= arr[i] <= 1000 ; 0<=i<=9

Input:
First line of input contains n, the number of elements in the input array
Take n elements into an array and print the odd numbers and even numbers
Take n elements into an array and print the odd numbers and even numbers
11
23
233
212
250
590
231
553
678
900
100
101
Total : 1 Discussion
Login
Romy
    
Used the following code and it worked but it's not accepted as a solution by the system
def get_odd_even(numbers):
    odd_nums = []
    even_nums = []
    for num in numbers[1:]:
        if num % 2 == 0:
            even_nums.append(num)
        else:
            odd_nums.append(num)
    return odd_nums, even_nums
    
numbers = [11, 23, 233, 212, 250, 590, 231, 553, 678, 900, 100, 101]
odd, even = get_odd_even(numbers)

print("Odd numbers:", odd)
print("Even numbers:", even)
Reply