In the beginning, you define your get_user_selection() function like this:
def get_user_selection():
user_imput = input("Enter a choice (Rock[0], Paper[1], Scissors[2]): ")
selection = int(user_input)
action = Action(selection)
return actionThen, in the next line, you redefine your function like this:
def get_user_selection():
choices = [f"{action.name}[{action.value}]" for action in Action]
choices_str = ", ".joint(choices)
selection = int(input(f"Enter a choice ({choices_str}): "))
action = Action(selection)
return actionAnd even after this, you forget about the previous definitions and you create a new, 3rd definition for your get_user_selection() function:
def get_user_selection():
selection = random.randint(0, len(Action) - 2)
action = Action(selection)
return actionSince the compiler reads the code sequentially, this last definition will be the one that will be used during the execution of your program. This last definition does not take any user input; it just randomizes a value in the allowed range.
I'd recommend thinking about why you have 3 definitions of the same function. Remove what you do not need. Or rename the function. Or comment out the unused variations.
Good luck!