# -*- coding: utf-8 -*- def guessing_game(): import random game = "y" higher_guesses = [] lower_guesses = [] while game == "y": rand_num = random.randint(1,100) print("The number is: " + str(rand_num)) tries = 0 ans_correct = 0 while tries < 10 and ans_correct != 1: print("you have used " + str(tries) + " tries") print("please pick a number from 1 to 100") player_choice = input() if(int(player_choice) in range(100) and int(player_choice) != 0): if(int(player_choice) < int(rand_num)): print("higher") higher_guesses.append(player_choice) elif(int(player_choice) == int(rand_num)): print("correct") elif(int(player_choice) > int(rand_num)): print("lower") lower_guesses.append(player_choice) tries = int(tries) + 1 else: print("invalid input") if(player_choice == rand_num): print("you win") else: print("you lose") print("it took you " + str(tries) + " tries") print("here are your guesses:") for item in lower_guesses: print(str(item)) for item in higher_guesses: print(str(item)) game = 0 while game != "y" and game != "n": if(game != "y" and game != "n"): print("invalid input") elif(game == "y" or game == "n"): print("restarting game...") print("would you like to play again? y/n") game = input("")