2 and 4 added

This commit is contained in:
Logen Kain 2017-02-11 16:21:29 -07:00
parent 33451d727a
commit cfd4315ce0
2 changed files with 38 additions and 1 deletions

View File

@ -16,4 +16,3 @@ try:
print(str(number) + ",is an " + evenOdd + " number") print(str(number) + ",is an " + evenOdd + " number")
except: except:
print("Only enter an integers!") print("Only enter an integers!")

View File

@ -0,0 +1,38 @@
#Random number 1:9 (including 1/9)
#have user guess, respond with high or low
#Keep going untill "exit" is typed
#keep track of number of guesses
import random
guesses = 0
playerGuess = None
answer = random.randint(1,9)
print("Welcome to the classic high/low game!!!")
while True:
playerGuess = input("Please enter an integer 1-9 or type 'exit' to quit: ")
if playerGuess != "exit":
try:
playerGuess = int(playerGuess)
except:
print ("Please only enter integers between 0 and 10, or type 'exit' to quit.")
continue
elif playerGuess == "exit":
break
if playerGuess == answer:
print("Congrats! You guessed right! ")
elif playerGuess > answer:
print("You guessed too high!")
elif playerGuess < answer:
print("You guessed too low!")
guesses += 1
print("You made", guesses, "guesses.")