Skip to content

Commit 0eedf05

Browse files
authored
Merge pull request #43 from Manju-Chinnanagoudar/Feature-Search-by
Update number_guessing.py
2 parents 8738e9b + d4aa073 commit 0eedf05

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

Number Guessing/number_guessing.py

+16-21
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import random, time
2-
print("Welcome to number guessing game !!!")
1+
import random
2+
import time
3+
print('Hello World! Welcome to the game')
34
time.sleep(2)
4-
#generate a random number
5-
x = random.randint(1, 10)
6-
print("The number is generated!!!")
7-
time.sleep(1)
8-
print("You have 4 chances to guess")
9-
#initialize the counter
5+
n = random.randint(1, 10)
6+
print('Number has been generated!!\nYou have 4 chnaces to guess the number')
7+
108
count = 4
11-
while count != 0:
12-
a = int(input("Guess the number : "))
13-
#if number guessed is correct, print correct
14-
if a == x:
15-
print("You are right, correct number is ", x)
16-
print("Congratulations! You won")
9+
10+
while count!=0:
11+
a = int(input('Guess the number: '))
12+
13+
if a == n:
14+
print("Yay! That's right. You won!")
1715
break
18-
#if guessed number is greater
19-
elif a > x:
20-
print("The number is less than ", a)
21-
#if guessed number is smaller
16+
elif a > n:
17+
print('The number is less than ', a)
2218
else:
23-
print("The number is greater than ", a)
24-
#decrease the counter after each guess
25-
count -= 1
19+
print('The number is greater than ', a)
20+
count=-1

0 commit comments

Comments
 (0)