-3
def check_guess(letter, guess):
    if letter == guess:
        result = "You are correct"
    elif letter < guess:
        result = "It is too low" + letter == guess
    elif letter > guess:
        result = "It is too high" + letter == guess        
    else:
        result = "It is an invalid input " + letter == guess
    return result

print (check_guess(raw_input("What is your guess (lower case) ?"), raw_input("Please input one lower case alpha! ")))

I would like to know why I can't show the string like "It is too low" in the solution?

Davis Broda
  • 4,102
  • 5
  • 23
  • 37
MorrisWong
  • 33
  • 3

3 Answers3

0

Your string addition with boolean result is causing the problem. try

result = "It is too low" + str(letter == guess)  

and this should do the trick. Also yes as others pointed out, post the code in your question, not just picture.

Better solution can be :

result = "It is too low %s" %(letter == guess)

Check this question

jkhadka
  • 2,443
  • 8
  • 34
  • 56
0

You did not specify what you want to display so either as hadi k stated in their answer:

result = "It is too low %s" %(letter == guess)

gives

"It is too low false"

or

result = "It is too low {} == {}".format(letter, guess)

gives

"It is too low a == b"

if letter = 'a' and guess = 'b'

Simon Black
  • 913
  • 8
  • 20
0

Is it necessary to check if letter equals guess in your if statements? If not, you can just return the string instead. Hope you get the idea.

def check_guess(letter, guess):
    if letter < guess:
        return 'It is too low'

print(check_guess('a', 'b'))
Luke
  • 744
  • 2
  • 7
  • 23