We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae68a78 commit 7b97a06Copy full SHA for 7b97a06
1 file changed
other/guess_the_number_userplay
@@ -0,0 +1,34 @@
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
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
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
31
32
33
34
+guess()
0 commit comments