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)
Output

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad