如何检查数组中每个项目的首字母? [英] How can I check the first letter of each item in an array?

查看:85
本文介绍了如何检查数组中每个项目的首字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个拉丁语翻译器,我不知道如何识别输入单词的第一个字母.我已经将输入转换为一个数组,每个项目都是一个新词,但是如何选择每个项目的每个首字母来确定它是否是辅音/元音/等?

I'm building a pig latin translator and I can't figure out how to identify the first letter of the entered words. I've converted the input to an array with each item being a new word, but how do I select each first letter of each item to determine if it's a consonant/vowel/etc.?

推荐答案

a = ['This', 'is', 'a', 'sentence']
for word in a:
    print(word[0])

输出:
Ť一世一个

Output:
T i a s

这篇关于如何检查数组中每个项目的首字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆