Skip to content

Commit

Permalink
Merge pull request #78 from rutuja060/main
Browse files Browse the repository at this point in the history
add guess game
  • Loading branch information
aman-raza authored Oct 7, 2020
2 parents 626d2e6 + f724a25 commit f8254fe
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions guess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# THIS IS A GUESS THE NUMBER GAME
import random

print("Hello, what is your name?")
name=input()

print("well," +name+ ",i am thinking of a number between 1 to 20.")
secretnumber=random.randint(1,20)

for guessesTaken in range(1,7):
print("Take a guess")
guess = int(input())
if guess < secretnumber:
print("Your guess is too low")
elif guess > secretnumber:
print("Your guess is too high")
else:
break


if guess == secretnumber:
print("good job,"+name+"!you guessed my number in " +str(guessesTaken)+ " guesses")
else:
print("nope. the number i was thinking of was"+str(secretnumber))

0 comments on commit f8254fe

Please sign in to comment.