Get the right direction

Report a typo

Write a Python program that defines an ENUM called Direction with four members: NORTH, SOUTH, EAST, and WEST. Each member should have a corresponding integer value, starting from 1 for NORTH and increasing by 1 for each subsequent member.

Then, write a function called get_direction_name that takes an integer value as an argument and returns the corresponding direction name as a string. For example, if the argument is 3, the function should return EAST. If an invalid argument is entered, return None.

Finally, the program prompts the user to enter an integer value representing a direction. It then uses the get_direction_name function to retrieve the corresponding direction name based on the entered value. The program then prints the obtained direction name.

Sample Input 1:

1

Sample Output 1:

The corresponding direction name is: NORTH
Write a program in Python 3
from enum import Enum

class Direction(Enum):
# Write your code here

def get_direction_name(value):
# Write your code here

# Main program
value = int(input())
name = get_direction_name(value)
print("The corresponding direction name is:", name)
___

Create a free account to access the full topic