It's word library from words import words
I chose a random word and I stuck here word_list= [letter if letter in used_letters else '-' for letter in word]
I did not understand that.
import random
from words import words
LIVES=7
def valid_word(words):
word=random.choice(words)
while ' ' in word or '_' in word:
words=random.choice(words)
return word.upper()
def hangman():
word=valid_word(words)
word_letters = set(word)
used_letters = set()
while len(word_letters) > 0 and LIVES > 0:
print(f"You have {LIVES} lives left and you have these letters",' '.join(used_letters))
word_list= [letter if letter in used_letters else '-' for letter in word]
print(word_list)
hangman()