gpt4 book ai didi

python - 检查变量的多个值

转载 作者:太空狗 更新时间:2023-10-30 00:41:15 24 4
gpt4 key购买 nike

<分区>

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = str(word)[0]
print first
if str(first) == "a" or "e" or "i" or "u" or "o":
print "vowel"
else:
print "consonant"

我想检查一个单词是否以元音或辅音开头。但是,这部分不起作用:if str(first) == "a"or "e"or "i"or "u"or "o"

那么如何检查第一个字母是“a”、“e”、“i”、“u”还是“o”?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com