我是Python的初学者。到目前为止我得到了这个:
vowels = 'aeiouAEIUO'
consonants = 'bcdfghjklmnñpqrstvwxyzBCDFGHJKLMNÑPQRSTVWXYZ'
a = input('Type a word: ')
for i in range(len(a)):
cont1 = 0
cont2 = 0
if a[i] in consonants:
cont1 = i - 1
cont2 = i + 1
if a [cont1] in vowels and a [cont2] in vowels:
print('consonant between vowels')
我想把音节分开。我想创建一个规则,当一个辅音在两个元音之间时,辅音必须连接到右边的元音,并打印由“-”分隔的音节 montoya=周一到周五 阿莫尔=阿莫尔 clase=类别
当然,这段代码会给出一个错误:IndexError:string index out of range。我不知道那是什么意思。你知道吗
谢谢
您可以使用
re
:相关问题 更多 >
编程相关推荐