I have this line of code in a hangman program
word_list = [letter if letter in used_letters else '-' for letter in word]
and it takes the word that was picked and puts '-' in place of the letters that weren't guessed yet.
I just don't understand how the line works. How is there an if statement and a for loop inside a list? What is this if statement doing if letter in used_letters
?
If someone could break it down for me I feel like it would make way more sense.