Skip to content

Commit 7d080c6

Browse files
Guessing the number (#26)
* snakegame * guess the number
1 parent 7b6face commit 7d080c6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

guess the number.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import random
2+
num = random.randint(1, 9)
3+
player_name = input("Hello mate, What's your name ?\n")
4+
guess_count = 0
5+
print("welcome ", player_name, ", are you ready to plat the guessing game ? (yes/no)")
6+
a = input()
7+
if a == "yes":
8+
print("I'm guessing a number between 1 to 9")
9+
while guess_count < 5:
10+
guess = int(input())
11+
guess_count += 1
12+
if guess < num:
13+
print('Your guess is too low')
14+
if guess > num:
15+
print('Your guess is too high')
16+
if guess == num:
17+
print("Hurray, you guessed it right!")
18+
if guess == num:
19+
print('You guessed the number in ' + str(guess_count) + ' tries!')
20+
else:
21+
print('You did not guess the number, The number was ' + str(num))
22+
else:
23+
print("hoping to see you soon again! :)")

0 commit comments

Comments
 (0)