检查单词的第一个字母是否是元音 [英] checking if the first letter of a word is a vowel
本文介绍了检查单词的第一个字母是否是元音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用python编写一个函数来检查给定单词的第一个字母(例如"ball")是大写还是小写的元音.例如:
I am trying to use python to write a function that checks whether the first letter of a given word, for instance "ball" is a vowel in either uppercase or lowercase. So for instance:
#here is a variable containing a word:
my_word = "Acrobat"
#letters in vowel as a list
the_vowel = ["a","e","i","o","u"]
如何检查"Acrobat"中的第一个字母是否为列表中的元音之一?我还需要考虑是大写还是小写?
How do a check that the first letter in "Acrobat" is one of the vowels in the list? I also need to take into consideration whether it is upper or lowercase?
推荐答案
尝试在元音中输入 my_word [0] .lower()
这篇关于检查单词的第一个字母是否是元音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文