New to python but have java experience. I was watching a fcc youtube video, and the bolded line in the code snippets below really bothers me. I understand what it does, but I don’t understand the syntax. It is just not logical. Is there another way to rewrite it in a single line? Essentially the line is iterating thru characters in the ‘word’ variable, and if the character is in the ‘used_letters’ list, then add it to a new list, otherwise add ‘-’ to the new list.
used_letters=[‘A’,‘L’] word_list = [letter if letter in used_letters else ‘-’ for letter in word]