Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit f371a63

Browse files
guessing_game
1 parent 012a9d3 commit f371a63

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import random
2+
3+
def genareted_number():
4+
5+
genareted_number=random.randint(1, 100)
6+
7+
8+
print("Welcome to the Guessing Game!")
9+
print("You heve maximum 10 chance.")
10+
11+
for attempts in range (0, 10):
12+
user_choice = int(input("Enter your number in 1 to 100 : "))
13+
attempts += 1
14+
15+
if user_choice < genareted_number:
16+
print("Too low! Try again.")
17+
elif user_choice>genareted_number:
18+
print("Too high! Try again.")
19+
else:
20+
print("Congratulations! You've guessed the number in", attempts, "attempts.")
21+
break
22+
else:
23+
print("Sorry, you've run out of attempts. The number was", genareted_number)
24+
25+
genareted_number()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /