Avatar ·

How to extract the even number from a list if all other values are odd, and vice versa?

📁 Advanced Python Topics, example

There can be two types of lists: one with all even numbers and one odd number, and another with all odd numbers and one even number. The list must contain at least three values.

Example lists:

[2, 4, 0, 100, 4, 11, 2602, 36] # should output 11 (as the single odd number)[160, 3, 1719, 19, 11, 13, -21] # should output 160 (as the single even number)

How to write code to output