File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import random
2+
3+ def guess():
4+ print("🎯 Welcome to Guess the Number game!")
5+ print("Rules are simple, guess a number between 0 and 20, and enter it below.")
6+ print("Only 5 Attempts are possible")
7+ print()
8+
9+
10+ computer = random.choice(range(21))
11+ print("Alright, lets go! Type your first guess 👇")
12+ print()
13+
14+ print(computer)
15+
16+ count = 0
17+ while True:
18+ user = int(input("Number: "))
19+ if count == 5:
20+ print("Try again, max only 5 Attempts")
21+ break
22+ if user == computer:
23+ print("🔥 Success! You've guessed it right!")
24+ break
25+ elif user < computer:
26+ print("Try some higher numbers!")
27+ count += 1
28+ elif user > computer:
29+ print("Not that high, try lower ones!")
30+ count += 1
31+
32+
33+
34+ guess()
You can’t perform that action at this time.
0 commit comments