Created
October 16, 2012 23:06
-
-
Save nicolasfig/3902642 to your computer and use it in GitHub Desktop.
Guess my number simple text 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 | |
guessesTaken = 0 | |
print("Hello what is your name?") | |
name = input() | |
number = random.randint(1,20) | |
print("Well",name,",I am thinking of a number between 1 and 20.") | |
while guessesTaken < 6: | |
print("Take a guess") | |
guess = input() | |
guess = int(guess) | |
guessesTaken = guessesTaken + 1 | |
if guess < number: | |
print("your guess is to low") | |
if guess > number: | |
print("Your guess is to high") | |
if guess == number: | |
break | |
if guess == number: | |
guessesTaken = str(guessesTaken) | |
print("Good job",name,"You guessed my number in",guessesTaken,"guesses!") | |
if guess != number: | |
number = str(number) | |
print("Nope, the number I was thinking of was",number) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment