Programming Examples

Create a Python program that removes even duplicate positive integer numbers (includes zero)


Create a Python program that removes even duplicate positive integer numbers (includes zero) from a list and prints the unique numbers in the order they first appeared.

If input is 4 3 2 1, then output should be 4 3 2 1.

If input is 0 0 0 0 1, then output should be 0 1.

If input is 1 1 3 3, then output should be 1 1 3 3.

Solution

nums = list(map(int, input("Enter numbers separated by space: ").split()))

seen_even = set()
result = []

for num in nums:
    if num % 2 == 0:  # even number (including 0)
        if num not in seen_even:
            result.append(num)
            seen_even.add(num)
    else:  # odd number → keep all occurrences
        result.append(num)

print("Output:", *result)
▶ RUN

Output/ Explanation:

Latest Current Affairs 2026 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad