So I have recently started programming python and I have one issue with this code. When the player gets the answer incorrect after using all their lives it should print the answer which it does but only the first time the layer plays i they play again they don't get told the correct answer if the get it wrong. It also does this when the player gets the answer correct. Plus the number the computer chooses stays the same when you use the play again function. Please try and help me but bear in mind my understanding cane be very limited in some aspects of python. I've included lots of comments to help others understand whats going on. I have included my code and what I get in the shell.

Code:

```
#imports required modules
import random
from time import sleep

#correct number variable created
num = 0
#generates number at random
comp_num = random.randint(1,10)
print('I\'m thinking of a number guess what it is...\n')

#main game code
def main():
    #lives created
    lives = 3
    #correct number variable reset
    num = 0
    while lives >= 1:
        #player guesses
        guess = int(input('Guess: '))
        if comp_num == guess:
            #if correct says well done
            input('\nWell Done! You guessed Correctly!\n')
            #player doesn't get told what the number is if there right
            num = num +1
            break
        elif comp_num >= guess:
            #if guess is too low tells player
            #one live taken for incorrect guess
            lives = lives -1
            print('\nToo low!\n')
            #player is told how many lives they have left
            print('You guessed incorrectly. You have',lives,'live(s) remaining.\n')
        elif comp_num <= guess:
            #if guess is too high tells player
            #one live taken for incorrect guess
            lives = lives -1
            print('\nToo high!\n')
            #player is told how many lives they have left
            print('You guessed incorrectly. You have',lives,'live(s) remaining.\n')

def end():
    #asks player if they want to play again
    play_again = input('Would you like to play again?[Y/N] ')
    while play_again.lower() == 'y':
        #if they do game resets and plays again
        if play_again.lower() == 'y':
            comp_num = random.randint(1,10)
            print('\nI\'m thinking of a number guess what it is...\n')
            main()
            play_again = input('Would you like to play again?[Y/N] ')
            if play_again.lower() == 'n':
                break
    if play_again.lower() == 'n':
        #if they don't game ends
        input('\nOk, Press enter to exit')
        exit()

main()

if num != 1:
        #if player guesses incorrectly they get told the correct awnser
        print('The number I was thinking of was...',comp_num,'!\n')

end()

```

SHELL:

```
I'm thinking of a number guess what it is...

Guess: 5

Well Done! You guessed Correctly!

The number I was thinking of was... 5 !

Would you like to play again?[Y/N] y

I'm thinking of a number guess what it is...

Guess: 5

Well Done! You guessed Correctly!

Would you like to play again?[Y/N] y

I'm thinking of a number guess what it is...

Guess: 5

Well Done! You guessed Correctly!

Would you like to play again?[Y/N] y

I'm thinking of a number guess what it is...

Guess: 5

Well Done! You guessed Correctly!

```