使用for循环猜测子手的单词

时间:2018-10-23 02:08:46

标签: python python-3.x

def get_guess(past_guesses):      
    """
    Checks if past_guesses is 1 letter, a letter or has been used before, and 
    prompts user to try again

    Args:past_guesses:a st, one letter long
    Returns: 'You need to enter one alphabetic character which you haven\'t 
    already guessed. Try again'

    Example:
    >>> get_guess([a, a])
    'You need to enter one alphabetic character which you haven\'t 
    already guessed. Try again'
    >>> get_guess([A, a])
    'You need to enter one alphabetic character which you haven\'t 
    already guessed. Try again'
    >>> get_guess([1])
    'You need to enter one alphabetic character which you haven\'t 
    already guessed. Try again'
    """
    counter = 0
    p = [x.lower() for x in past_guesses]
    for i in past_guesses:
        if i in past_guesses:
            counter += 1
        if counter > 2:
            result = "'You need to enter one alphabetic character which you\
            haven't already guessed. Try again'"
        elif :
            result = p, 'is in the word'
        return result

嗨。我很难弄清楚如何编写代码来帮助我们从已经被猜为子手单词的字母列表(past_guessed)中写出一个字符串。

0 个答案:

没有答案