【发布时间】:2016-11-09 21:07:33
【问题描述】:
from collections import Counter
inp = input("Please enter some text: ")
vowels = set("aeiouAEIOU")
if inp in vowels:
res = Counter(c for c in inp if c in vowels)
print (res.most_common())
elif inp not in vowels:
print("No vowels entered.")
如果在用户输入中找到任何元音,或者如果没有,则打印一条消息,代码旨在输出元音。目前,如果用户输入了多个元音,则代码不起作用,因为它会打印“未输入元音”行。如何纠正这个错误。
【问题讨论】:
标签: python if-statement input set counter