#what is the number game--------
#-----redSara-----2011-July-18

# import from libary
import random
import time
# create the variables attempts, yes, no, range of numbers

attempts=0
no="no"
yes="yes"
the_number = random.randint(1, 100)
player_game = ""
#start
#Greets the player and ask for his/her name
player_name = raw_input("Hello! What is your name? ")
print "Nice to meet you,", player_name + "!"
#Ask player if he/she wants to play a game
while player_game!=no and player_game!=yes:
player_game = raw_input ("Do you want to play a game? yes/no ")
while True:
if player_game == no:
print ("Oh :( . Then maybe next time " + player_name )
print ("Good bye " + player_name)
break
if player_game == yes:
attempts = 0
print ("Awesome :D . Let's play 'Guess my number!'" )
print ("I am thinking of a number between 1 and 100." )
print ("Try to guess it with maximal 5 attempts." )
while True:
try: guess = int(raw_input("Take a guess: "))
except: #wasn't able to make it an int
print ("That is not a number," + player_name + "!" )
continue #skip the rest of this iteration
if guess < 1 or guess > 100:
print ("The number is not between 1 and 100." )
elif guess > the_number:
print ("Your guess is too high." )
attempts = attempts +1
elif guess < the_number:
print ("Your guess is too low." )
attempts = attempts +1
elif guess  == the_number:
attempts = attempts +1
print ("You win! The number was " + the_number )
print ("Congratulation, you needed " + str(attempts) + "tries!" )
break
if attempts == 5:
print ("You have made 5 attempts, " + player_name )
print ("GAME OVER" )
player_game = ""
while player_game!=no and player_game!=yes:
player_game = raw_input ("Do you want to play again? yes/no ")
break