text = 'Python Java and C are popular languages but Java and C ' 'are statically typed whereas Python is dynamically typed'

forbidden = ['Java', 'C', 'statically']

print("Løsning 1")

def eliminate(text, forbidden_words):
    forbidden_words = frozenset(forbidden_words)
    content = text.split()
    #print(content)
    new_content = []
    for word in content:
        if word in forbidden_words:
            new_content.append('*' * len(word))
        else:
            new_content.append(word)
    #print(new_content)
    new_text = ' '.join(new_content)
    #print(new_text)
    return new_text

print(eliminate(text, forbidden))

print("Løsning 2")

def eliminate(text, forbidden_words):
    return ' '.join([('*' * len(word) if word in forbidden_words else word)
                     for word in text.split()])

print(eliminate(text, forbidden))

print("Løsning 3")

def eliminate(text, forbidden_words):
    content = text.split()
    new_content = ['*' * len(word) if word in forbidden_words else word
                   for word in content]
    return ' '.join(new_content)

print(eliminate(text, forbidden))

print("Løsning 4")

def eliminate(text, *forbidden_words):
    forbidden_words = frozenset(forbidden_words)
    content = text.split()
    new_content = ['*' * len(word) if word in forbidden_words else word
                   for word in content]
    return ' '.join(new_content)

print(eliminate(text, 'Java', 'C', 'statically'))
print(eliminate(text, 'Java'))
