Adding integers in string to find the number of tries in a word guess problem

Viewed 9

I'm writing a word guesser program but I can't seem to add the number of tries the user has # attempted if the guess is incorrect. How do I add integers in the string? Is it possible to do it?

secret_word = "code"
guess = input('Enter your guess: ')
number_of_tries = int(1)
if secret_word.lower() == guess.lower():
  print("Correct! You got it in " + str(number_of_tries) +" tries!")
else:
  print("Sorry. That is incorrect. You have " + str(number_of_tries) + str(1) + " tries left.")
0 Answers
Related