[Python] Is there a program that will only return the consonants in a word python

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to write a program that asks the user for a word and only returns the consonants. But I am stuck with this program, I would expect this program to do what I have mentioned above, but all it does is returns the word row by row.

    original = input('Enter a word:')
    word = original.lower()
    first = word[0]
    second = word[1]
    third = word[2]
    fourth = word[3]
    fifth=word[4]


    if first == "a" or "e" or "i" or "u":
    print (first)
    else:
    print ("")
    if second == "a" or "e" or "i" or "u":
    print (second)
    else:
    print ("")
    if third == "a" or "e" or "i" or "u":
    print (third)
    else:
    print ("")
    if fourth == "a" or "e" or "i" or "u":
    print (fourth)
    else:
    print ("")
    if fifth == "a" or "e" or "i" or "u":
    print (fifth)
    else:
    print ("")

    Continue reading...

Compartilhe esta Página