Help for newbie with Python task

Hi guys,
I am learning Python and there is a task I cannot figure out. These are the instructions:

create letter_guess() function that gives user 3 guesses

  • takes a letter character argument for the answer letter
  • gets user input for letter guess
  • calls check_guess() with answer and guess
  • End letter_guess if
    • check_guess() equals True, return True
    • or after 3 failed attempts, return False

I’ve tried figuring this out for ages… can’t figure out how to write this correctly.
I would really appriciate if someone could show me how they would write this so I could go over it and see how its done…

Thank you so much in advance.

why don’t you show your code first? it is easier to gouge what help you need seeing what you have attempted

Hi there, thanks for the reply.
I was able to make the end result be what was asked for, but I am missing check_guess() function entirely.
I think I lack the understanding of how to make such 2 functions work together.

This is what I wrote:

answer = "p"
guess_1 = input("guess a letter: ") 
guess_2 = input("guess again: ") 
guess_3 = input("and again: ")

def letter_guess(guess_1,guess_2, guess_3):

    if guess_1.lower() == "p":
        return print("Guess number 1 is true")

    elif guess_2.lower() == "p":
        return print("Guess number 2 is true")

    elif guess_3.lower() == "p":
        return print("Guess number 3 is true")


letter_guess(guess_1,guess_2, guess_3)`

End result would look like this:
guess a letter: s
guess again: e
and again: p
Guess number 3 is true

This is just not exactly what the exercise was.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.