Implementing a simple number filter with the walrus operator

Report a typo

You are required to write a program that reads a series of integers from user input until the user enters "done". The program should then output two lists: one containing all the even numbers entered and the other containing all the odd numbers entered. You should use the Walrus Operator (:=) to simplify the code.

Consider using the Walrus Operator (:=) when checking the user input and determining whether it's an even or odd number. This will allow you to both check and use the value in a single line, simplifying your code.

Ensure to utilize the Walrus Operator (:=) in your solution to simplify the code.

Sample Input 1:

2
4
6
8
done

Sample Output 1:

Even Numbers: [2, 4, 6, 8]
Odd Numbers: []
Write a program in Python 3
even_numbers = []
odd_numbers = []
# Your code here

print(f'Even Numbers: {even_numbers}')
print(f'Odd Numbers: {odd_numbers}')

Create a free account to access the full topic