Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 3, 2021 12:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/274dde065a820a29cbabd3f491a19644 to your computer and use it in GitHub Desktop.
Save amankharwal/274dde065a820a29cbabd3f491a19644 to your computer and use it in GitHub Desktop.
def check_guess(guess, answer):
global score
still_guessing = True
attempt = 0
while still_guessing and attempt < 3:
if guess.lower() == answer.lower():
print("Correct Answer")
score = score + 1
still_guessing = False
else:
if attempt < 2:
guess = input("Sorry Wrong Answer, try again")
attempt = attempt + 1
if attempt == 3:
print("The Correct answer is ",answer )
score = 0
print("Guess the Animal")
guess1 = input("Which bear lives at the North Pole? ")
check_guess(guess1, "polar bear")
guess2 = input("Which is the fastest land animal? ")
check_guess(guess2, "Cheetah")
guess3 = input("Which is the larget animal? ")
check_guess(guess3, "Blue Whale")
print("Your Score is "+ str(score))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment