forked from LewisAndClark-CSD/Chapter_3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallenge3.py
More file actions
34 lines (28 loc) · 961 Bytes
/
Challenge3.py
File metadata and controls
34 lines (28 loc) · 961 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
31
32
33
34
# Guess My Number
#
# The computer picks a random number between 1 and 100
# The player tries to guess it and the computer lets
# the player know if the guess is too high, too low
# or right on the money
import random
print("\tWelcome to 'Guess My Number'!")
print("\nI'm thinking of a number between 1 and 100.")
print("You have five geusses to geuss the number I'm thinking of.\n")
# set the initial values
the_number = random.randint(1, 100)
guess = int(input("Take a guess: "))
tries = 1
# guessing loop
while guess != the_number and tries < 10:
if guess > the_number:
print("Lower...")
elif guess < the_number:
print("Higher...")
guess = int(input("Take a guess: "))
tries += 1
if tries == 10:
print("Opps, you took too many tries dummy.")
else:
print("You guessed it! The number was", the_number)
print("And it only took you", tries, "tries!\n")
input("\n\nPress the enter key to exit.")