Created
June 21, 2014 19:18
-
-
Save piggykid1/bf9cdf216e436fea64d6 to your computer and use it in GitHub Desktop.
Python Guessing Game
This file contains 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 | |
number = random.randint(1, 1000) | |
guesses = 0 | |
while guesses < 10: | |
guess = int(raw_input("Enter an integer from 1 to 1,000: ")) | |
guesses +=1 | |
print "this is your %d guess" %guesses | |
if guess < number: | |
print "guess is low" | |
elif guess > number: | |
print "guess is high" | |
elif guess == number: | |
break | |
if guess == number: | |
guesses = str(guesses) | |
print "You guess it in : ", guesses + " guesses" | |
if guess == number: | |
guesses = str(guesses) | |
print "You guess it in : ", guesses + " guesses" | |
if guess != number: | |
number = str(number) | |
print "The secret number was", number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment