python:计算用户输入词中元音或辅音的数量

Zen*_*ami 3 python

我是大学新生,正在参加python编程课程.目前,我正在努力使程序根据用户的输入计算元音或辅音的数量,以确定模式.

目前,我已经制作了两个列表,我正在试图找出如何编程python来计算元音/辅音.

这就是我到目前为止 - 请记住,我已经在两端工作,中心是计数的地方.

#=======================================#
#Zane Blalock's Vowel/Consonants Counter#
#=======================================#

print("Welcome to the V/C Counter!")

#Make List
vowels = list("aeiouy")
consonants = list("bcdfghjklmnpqrstvexz")

complete = False
while complete == False:
    mode = input("What mode would you like? Vowels or Consonants?: ").lower().strip()
    print("")
    print("You chose the mode: " + str(mode))
    print("")
    if mode == "vowels":
        word = input("Please input a word: ")
        print("your word was: " + str(word))
        print("")



        choice = input("Are you done, Y/N: ").lower().strip()
        if choice == "y":
            complete = True
        else:
            print("Ok, back to the top!")
    elif mode == "consonants":
        word = input("please input a word: ")
        print("your word was: " + str(word))
        print("")


        choice = input("Are you done, Y/N: ").lower().strip()
        if choice == "y":
            complete = True
        else:
            print("Ok, back to the top!")
    else:
        print("Improper Mode, please input a correct one")

print("Thank you for using this program")
Run Code Online (Sandbox Code Playgroud)

eum*_*iro 12

number_of_consonants = sum(word.count(c) for c in consonants)

number_of_vowels = sum(word.count(c) for c in vowels)
Run Code Online (Sandbox Code Playgroud)