# Arup Guha
# 1/11/2013
# Solution to Programming Knights Practice Program Chapter 4 Problem 8
# Censored Message

def main():

    replacements = {}

    # Get the first censored word.
    print("Please enter your list of censored words.")
    word = input("Enter no to indicate the end of your list.\n")

    # Loop till there are no more replacements.
    while word != "no":

        # Get the replacement and store it.
        kosherword = input("What is the replacement for this word?\n")
        replacements[word] = kosherword

        # Prompt for the next entry.
        word = input("Enter the next word, or no to end the list.\n")


    # Get the sentence and split it into tokens.
    sentence = input("Enter a sentence to censor.\n")
    tokens = sentence.split()

    # Go through each word separately.
    for i in range(len(tokens)):

        # This word is illegal. Replace it!
        if tokens[i] in replacements:
            print(replacements[tokens[i]]+" ", end = "")

        # Just print this one out; it's okay.
        else:
            print(tokens[i]+" ", end = "")


main()
