forked from ghostmkg/programming-language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessingGame.py
More file actions
27 lines (17 loc) · 789 Bytes
/
GuessingGame.py
File metadata and controls
27 lines (17 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import random
print("Hi welcome to the game, This is a number guessing game.\nYou got 7 chances to guess the number. Let's start the game")
number_to_guess = random.randrange(100)
chances = 7
guess_counter = 0
while guess_counter < chances:
guess_counter += 1
my_guess = int(input('Please Enter your Guess : '))
if my_guess == number_to_guess:
print(f'The number is {number_to_guess} and you found it right !! in the {guess_counter} attempt')
break
elif guess_counter >= chances and my_guess != number_to_guess:
print(f'Oops sorry, The number is {number_to_guess} better luck next time')
elif my_guess > number_to_guess:
print('Your guess is higher ')
elif my_guess < number_to_guess:
print('Your guess is lesser')