Skip to content

Commit 1c5930b

Browse files
authored
'try' this lol
1 parent 6949a3a commit 1c5930b

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

Number/numbergame.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
number = 777
1+
SECRET = 777
22

33
print("In this program you will need to guess the number I am thinking of")
4-
54
print("I am thinking of a number between 1 and 800")
65

7-
while number == 777:
8-
guess = input()
9-
10-
guess = int(guess)
11-
12-
if guess < 777:
13-
print("Your guess is too low! Please try again.")
14-
15-
if guess > 777:
16-
print("Your guess is too high! Please try again.")
17-
18-
if guess == 777:
19-
print("Well done!! Your guess is correct!")
20-
21-
break
6+
while True:
7+
try:
8+
guess = int(input())
9+
10+
if guess < SECRET:
11+
print("Your guess is too low! Please try again.")
12+
elif guess > SECRET:
13+
print("Your guess is too high! Please try again.")
14+
else:
15+
print("Well done!! Your guess is correct!")
16+
break
17+
except ValueError:
18+
print("Please enter a valid number.")

0 commit comments

Comments
 (0)