Skip to content

Commit 284c7ba

Browse files
Solution to guessingGame challenge
1 parent d1a5d2e commit 284c7ba

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

guessingGameSolution

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Create a guessing game program:
2+
3+
import random
4+
randomNumber = random.randint(1,100)
5+
6+
# randomNumber is a variable from 1 to 100 that will be
7+
# chosen everytime the program is run
8+
9+
print('Welcome to the guessing game!')
10+
while True:
11+
print('I want you to guess a number from 1-100')
12+
13+
usrInput = input()
14+
usrInput = int(usrInput)
15+
16+
if(usrInput > randomNumber):
17+
print('You guessed too high!')
18+
if(usrInput < randomNumber):
19+
print('You guessed too low!')
20+
21+
if(usrInput == randomNumber):
22+
print('You guessed my secret number!')
23+
print('You won the game!')
24+
break
25+
26+
print('End of Program')

0 commit comments

Comments
 (0)