How can I replace the vowels of a word with underscores in python?
Question: I'm a beginner learning the python language and I'm stumped on how take the
vowels of a word and replacing them with an underscore.

So far this is what I have come up with and it just doesn't work

    
    
    word = input("Enter a word: ")
    new_word = ""
    vowels = "aeiouy"
    
    
    for letter in word:
        if letter != vowels:
            new_word += word
        else:
           new_word += "_"
           print(new_word)
    


Answer: You can use `string.translate` and `maketrans`.

    
    
    from string import maketrans
    
    vowels = "aeiouy"
    t = "______"
    st = "trying this string"
    tran = maketrans(vowels, t)
    
    print st.translate(tran)
    # Gives tr__ng th_s str_ng
    

You may also want to check uppercases.

