#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Dec  5 13:33:57 2017

@author: Muriel
"""

import random

def print_header():
    print("\tWelcome to 'Guess My Number'!")
    print("\tNow you pick up a number between 1 and 100.")
    print("\tI will try to guess it in as few attempts as possible.\n")


def print_footer(thenumber, tries):
    print("I guessed it! The number was",thenumber)
    print("And it only took me", tries, "tries!\n")
    print("\n\nPress the enter key to exit.")    
    
def main():
    # print the greeting banner
    print_header()
    
    # set the initial values
    
    thenumber=random.randint(1,100)
    thenumber=int(input("Pick up a number"))
    Lowest = 1
    Highest = 100
    tries = 1
    guess=random.randint(1,100)
    
    while  guess!=thenumber:
        print("Now I start a guess",guess)
        if guess>thenumber:
            print("lower")
            Lowest=Lowest
            Highest=guess
            guess=(Lowest+guess)//2
            
        else:
            print("higher")
            Lowest=guess
            Highest=Highest
            guess=(Highest+guess)//2
        tries+=1
    print_footer(thenumber, tries)

main()
