-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbetter_guessing_game.py
More file actions
30 lines (26 loc) · 883 Bytes
/
better_guessing_game.py
File metadata and controls
30 lines (26 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""guess_game_fun
Guess Game with a Function
In this project the guess game is recast using a function"""
import random
computers_number = random.randint(1,100)
PROMPT = 'What is your guess? '
def do_guess_round():
"""Choose a random number, ask the user for a guess
check wether the guess is true
and repeat until the user is correct"""
computers_number = random.randint(1,100) #Added
while True:
players_guess = raw_input(PROMPT)
if computers_number == int(players_guess):
print('Correct!')
break
elif computers_number > int(players_guess):
print('Too Low')
else:
print('Too high')
while True:
# Print statements added:
print("Starting a new Round!")
print("Let the guessing begin!!!")
do_guess_round()
print("") # blank line