day_12

import random




print('''

/ _ \_ _ ___ ___ ___ /__ \ |__ ___ /\ \ \_ _ _ __ ___ | |__ ___ _ __

/ /_\/ | | |/ _ \/ __/ __| / /\/ '_ \ / _ \ / \/ / | | | '_ ` _ \| '_ \ / _ \ '__|

/ /_\| |_| | __/\__ \__ \ / / | | | | __/ / /\ /| |_| | | | | | | |_) | __/ |

\____/ \__,_|\___||___/___/ \/ |_| |_|\___| \_\ \/ \__,_|_| |_| |_|_.__/ \___|_|

Welcome to the number guessing game!

I'am thinking a number between 1 and 100.

Choose a difficulty. Type 'easy' or 'hard' to guess the number.

''')


difficulty = input("Choose a difficulty. Type 'easy' or 'hard' to guess the number.")


if difficulty.lower() == 'easy':

chance = 10

elif difficulty.lower() == 'hard':

chance = 5

else:

print('wrong input')


ans_number = random.randint(1, 101)




def checknumber(user_input, ans_number):

if int(user_input) > ans_number:

return 'Too high'

elif int(user_input) < ans_number:

return 'Too low'

else:

return 'You got it'

while chance >= 0:

if chance <= 0:

print("You've run out of guesses, you lose")

break

else:

user_input = input("You have {} attempts remaining to guess the number.\n Make a guess".format(chance))

ans = checknumber(user_input, ans_number)

if ans == 'Too high':

print(ans)

print('guess again')

chance -= 1

elif ans == 'Too low':

print(ans)

print('guess again')

chance -= 1

else:

print(ans)

break