import random

words = ['apple', 'banana', 'orange', 'strawberry', 'grapefruit']
alphabet = set('abcdefghijklmnopqrstuvwxyz')
high_scores = []

while True:
    word = random.choice(words)
    word_letters = set(word)
    used_letters = set()
    score = 0

    while len(word_letters) > 0:
        print('You have used these letters: ', ' '.join(used_letters))
        word_list = [letter if letter in used_letters else '_' for letter in word]
        print('Current word: ', ' '.join(word_list))

        user_letter = input('Guess a letter: ').lower()
        if user_letter in alphabet - used_letters:
            used_letters.add(user_letter)
            if user_letter in word_letters:
                word_letters.remove(user_letter)
                score += 1
        elif user_letter in used_letters:
            print('You have already used that letter. Guess another letter.')
        else:
            print('Invalid character. Please try again.')

    print(f'Congratulations! You guessed the word {word}!')
    high_scores.append(score)
    print(f'Your current score is: {score}')
    print(f'High scores: {high_scores}')

    play_again = input('Do you want to play again? (Y/N) ').lower()
    if play_again == 'n':
        break
You have used these letters:  
Current word:  _ _ _ _ _
You have used these letters:  f
Current word:  _ _ _ _ _
You have used these letters:  g f
Current word:  _ _ _ _ _
You have used these letters:  g s f
Current word:  _ _ _ _ _
You have used these letters:  g a s f
Current word:  a _ _ _ _
You have used these letters:  a l g s f
Current word:  a _ _ l _
You have used these letters:  a l g s f m
Current word:  a _ _ l _
You have used these letters:  a l p g s f m
Current word:  a p p l _
Congratulations! You guessed the word apple!
Your current score is: 4
High scores: [4]
You have used these letters:  
Current word:  _ _ _ _ _ _ _ _ _ _
You have used these letters:  s
Current word:  s _ _ _ _ _ _ _ _ _
You have used these letters:  t s
Current word:  s t _ _ _ _ _ _ _ _
You have used these letters:  r t s
Current word:  s t r _ _ _ _ r r _
You have used these letters:  r a t s
Current word:  s t r a _ _ _ r r _
You have used these letters:  a r s t w
Current word:  s t r a w _ _ r r _
You have used these letters:  a r s j t w
Current word:  s t r a w _ _ r r _
You have used these letters:  a l r s j t w
Current word:  s t r a w _ _ r r _
You have used these letters:  b a l r s j t w
Current word:  s t r a w b _ r r _
You have used these letters:  b a l e r s j t w
Current word:  s t r a w b e r r _
You have already used that letter. Guess another letter.
You have used these letters:  b a l e r s j t w
Current word:  s t r a w b e r r _
Congratulations! You guessed the word strawberry!
Your current score is: 8
High scores: [4, 8]