I'm getting PEP257 error with this part of code. I'm aware that adding more than 3 if/elifs causes this, but I'm unsure how to properly fix this.
I've tried to group up the ifs/elifs but that made it too complicated for me and I havent found any other good solutions from Dr. Google.
def determine_winner(name: str, user_choice: str, computer_choice: str, reverse_name: bool = False) -> str:
"""
Determine the winner returns a string that has information about who won.
You should use the functions that you wrote before. You should use check_user_choice function
to validate the user choice and use normalize_user_name for representing a correct name. If the
function parameter reverse is true, then you should also reverse the player name.
NB! Use the previous functions that you have written!
:param name:player name
:param user_choice:
:param computer_choice:
:param reverse_name:
:return:
"""
user_choice = user_choice.lower()
computer_choice = computer_choice.lower()
if computer_choice == "rock":
pass
elif computer_choice == "paper":
pass
elif computer_choice == "scissors":
pass
else:
return "There is a problem determining the winner."
if reverse_name:
name = reverse_user_name(name)
if user_choice == computer_choice:
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence it is a draw."
elif user_choice == "rock":
if computer_choice == "paper":
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence computer wins."
else:
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence " + \
normalize_user_name(name) + " wins."
elif user_choice == "scissors":
if computer_choice == "paper":
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence " + \
normalize_user_name(name) + " wins."
else:
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence computer wins."
elif user_choice == "paper":
if computer_choice == "scissors":
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence computer wins."
else:
return normalize_user_name(
name) + " had " + user_choice + " and computer had " + computer_choice + ", hence " + \
normalize_user_name(name) + " wins."
else:
return "There is a problem determining the winner."
Should not show the PEP257 error.