Last active
August 29, 2015 14:01
-
-
Save tcz/a3e5f34400a9fd1ca602 to your computer and use it in GitHub Desktop.
Benedek python practice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import sys | |
enter = "Please Press Enter To Continue..." | |
print "Hello! Welcome to a Guessing game!" | |
print "Please Guess A number between 1 - 100!" | |
computernum = random.randint(1, 100) | |
computernum = str(computernum) | |
guesses = 3 | |
for try_number in range(1, guesses + 1): | |
while (True): | |
Guess = raw_input("My %d. Guess Is: " % try_number) | |
if Guess.isdigit(): | |
break | |
print "Please enter an integer!" | |
if Guess == computernum: | |
print "YOU WIN!" | |
raw_input (enter) | |
sys.exit(0) | |
elif try_number < guesses: | |
print "Sorry, try again!" | |
print "YOU HAVE %d GUESSES REMAINING!" % (guesses - try_number) | |
continue | |
if int(Guess) > int(computernum): | |
print "Okay, it's LESS than your guess" | |
else: | |
print "Okay, it's GREATER than your guess!" | |
print "Sorry, you lose the game!" | |
computernum = str(computernum) | |
print "The computers number was "+computernum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment