Opposite direction

Report a typo

You are given an enum called Direction that represents different directions: North, South, East, and West. You need to write a function called is_opposite that takes two Direction enum values as input and returns True if they are opposite directions (i.e., North/South or East/West) and False otherwise. However, the catch is that you cannot compare the enum values using their integer values or their string names. Instead, it would be best to use the identity comparison (is, is not) to compare the two enum values.

Sample Input 1:

North, South

Sample Output 1:

True
Write a program in Python 3
from enum import Enum

class Direction(Enum):
North = 1
South = 2
East = 3
West = 4

def is_opposite(dir1: Direction, dir2: Direction) -> bool:
pass


dir1, dir2 = input().split(", ")
print(is_opposite(Direction[dir1], Direction[dir2]))
___

Create a free account to access the full topic