Python 太复杂的PEP257错误,不确定如何修复

Python 太复杂的PEP257错误,不确定如何修复,python,pep,Python,Pep,这部分代码出现了PEP257错误。我知道添加3个以上的if/elifs会导致此问题,但我不确定如何正确修复此问题 我曾尝试将ifs/elifs进行分组,但这对我来说太复杂了,我还没有从谷歌博士那里找到任何其他好的解决方案 def determine_winner(name: str, user_choice: str, computer_choice: str, reverse_name: bool = False) -> str: """ Determine the wi

这部分代码出现了PEP257错误。我知道添加3个以上的if/elifs会导致此问题,但我不确定如何正确修复此问题

我曾尝试将ifs/elifs进行分组,但这对我来说太复杂了,我还没有从谷歌博士那里找到任何其他好的解决方案

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."

不应显示PEP257错误。

利用
return
结束执行这一事实

    user_choice = user_choice.lower()
    computer_choice = computer_choice.lower()

    if computer_choice not in {"rock", "paper", "scissors"}:
        return "There is a problem determining the winner."

    if reverse_name:
        name = reverse_user_name(name)

    choices = normalize_user_name(name) + " had " + user_choice + " and computer had " + computer_choice

    if user_choice == computer_choice:
        return choices + ", hence it is a draw."

    if user_choice == "rock":
        if computer_choice == "paper":
            return choices + ", hence computer wins."
        return choices + ", hence " + normalize_user_name(name) + " wins."

    if user_choice == "scissors":
        if computer_choice == "paper":
            return choices + ", hence " + normalize_user_name(name) + " wins."
        return choices + ", hence computer wins."

    if user_choice == "paper":
        if computer_choice == "scissors":
            return choices + ", hence computer wins."
        return choices + ", hence " + normalize_user_name(name) + " wins."

    return "There is a problem determining the winner."

什么工具显示PEP257错误?这不是错误;这是一个与docstring用法相关的警告。它可能详细阐述了它认为问题是什么。看见这可能是因为您在自己的行中有一个开头
”。请使用一个集合,而不是一个列表来检查是否进入