Skip to content

Instantly share code, notes, and snippets.

@tcz
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcz/a3e5f34400a9fd1ca602 to your computer and use it in GitHub Desktop.
Save tcz/a3e5f34400a9fd1ca602 to your computer and use it in GitHub Desktop.
Benedek python practice
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