dict = {} for line in open("words.txt"): word = line.strip() final_letter = word[-1] dict[final_letter] = word print(dict)