【发布时间】:2021-10-11 01:55:06
【问题描述】:
我需要确定这些单词是否以元音开头。
year= ["january","february","march","april","may","june","july","august","september","october","november","december"]
vowels = "aeiou"
for month in range(len(year)):
if month.startswith(vowels):
if_vowel = "Yes"
else:
if_vowel = "No"
print("Does the month of {0} start with a vowel? {1}".format(year[i],if_vowel)
理想情况下,它会根据月份是否以元音开头打印是或否
【问题讨论】:
-
没有一个月份名称以“aeiouy”开头(这是您最初测试的)。
-
嗨!请不要忘记在您的帖子中包含一个实际问题!我不清楚您实际上遇到了这个问题的哪一部分。解释器是否抛出异常(您没有预料到)?请包括那个!它是否返回了意外的输出?请包括显示的内容和您想要的内容!
标签: python for-loop if-statement