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 b6e3d11 commit 4d9a2d7Copy full SHA for 4d9a2d7
02.python-intro/debugging_exercise.py
@@ -0,0 +1,18 @@
1
+# import random
2
+
3
+# pick a random number for the user to guess
4
+rand = random.randint(1, 100)
5
6
+print('Guess a number between 1 and 20.')
7
+guess = int(input()) # number needs to be an integer
8
9
+while guess != rand: # if the guess is not equal to the random number, you have to guess again
10
+ if guess > rand: # if the guess is too high, tell the user.
11
+ print('Too low. Guess again.')
12
+ else: # if the guess is too low, tell the user.
13
+ print('Too high. Guess again.')
14
15
+ print('Enter a new guess: ')
16
+ guess = input()
17
18
+print(f'You got it! The number was {rand}')
0 commit comments