#!/usr/bin/env python3

#       guess_me_0.4_stable.py
#
#       Copyright 2009 Aneesh <aneesh.nl@gmail.com>
#
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.



print("Number Guessing Game")

import random

r = random.randint(1, 100) # To generate a random number between 1 and 100


level = int(input("Choose your level. \n1.Easy\n2.Medium\n3.Hard\n"))

if level == 2:
    chance = 7   # 2. Medium, So 7 chances
elif level == 3:
    chance = 4   # 3. Hard,   So 4 chances
else:
    chance = 10   # All else, So 10 chances

i = 0
score = chance*10 # calculate initial score

print("You have {0} chances.".format(chance - i))

for i in range(1, chance + 1):
    guess=int(input("Enter your guess : "))
    if r == guess: # Correct guess
        print("Congratulations!!! You have guessed the number.\nThe score is {0} out of {1}".format(score,(chance*10)))
        print("You have used {0} chances".format(i))
        exit()
    elif (r > guess) & (i != (chance - 1)): # i != 1 --> If it is not Last chance
        print("Your guess is too low !!! Guess a higher number.")
        print("You have {0} chances left.".format(chance - i))
        score = score - 10
    elif (i != (chance - 1)): # i != 1 --> If it is not Last chance
        print("Your guess is high !!! Guess a lower number.")
        print("You have {0} chances left.".format(chance - i))
        score = score - 10

print("Sorry, you have lost... Better luck next time. The number was {0}".format(r))
