Skip to content

Commit 4d9a2d7

Browse files
committed
add bug-filled script for debugging exercise
1 parent b6e3d11 commit 4d9a2d7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

02.python-intro/debugging_exercise.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)