-
Notifications
You must be signed in to change notification settings - Fork 0
/
guess.py
31 lines (26 loc) · 923 Bytes
/
guess.py
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
# This is a guess the number game.
import random
from customprint import print
print("Hello. What is your name?")
name = input()
low = 0
high = 20
secretNumber = random.randint(low, high)
print("Well, " + name + ", I am thinking of a number between " + str(low) + " and " + str(high))
# Ask the player to guess 6 times.
for guessesTaken in range(1,7):
print("Take a guess.", "jj", "testerinooooopppppppppppppppppp", "asdasdas")
try:
guess = int(input())
except ValueError:
print("A number, dipshit!")
if guess < secretNumber:
print("Your guess is too low.")
elif guess > secretNumber:
print("Your guess is too high.")
else:
break # correct guess
if guess == secretNumber:
print("Good job, " + name + "! You guessed my number in " + str(guessesTaken) + " guesses.")
else:
print("Nope. The number I was thinking of was " + str(secretNumber) + ".")