Skip to content

Instantly share code, notes, and snippets.

@yosefsadek
Created January 17, 2020 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosefsadek/f1d9a60dc463126f6593e77a9bcf16de to your computer and use it in GitHub Desktop.
Save yosefsadek/f1d9a60dc463126f6593e77a9bcf16de to your computer and use it in GitHub Desktop.
py
answer = 15
attempts= 0
userentry=""
#a loop that repeats while the users guess is not the same as the answer
while answer != userentry:
userentry = int(input("Enter a number between 1 and 20 "))
#each time through the loop 1 is added to the number of attempts
attempts=attempts+1
#after the loop it will say how many attempts it took
print("Well done you correctly guessed the number it took you " + str(attempts) + " attempts")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment