字符串是“banana”。我已经创建了所有的子串,现在想要过滤那些以元音开头或不以元音开头的子串。我想使用任何操作,但不知道如何使用它。
l = ['', 'an', 'anan', 'na', 'ana', 'n', 'a', 'anana', 'ba', 'b', 'ban', 'nan', 'banan', 'banana', 'nana', 'bana']
vowels = 'aeiou'
for word in l:
if word.startswith( any(vowels)): #this gives error
print("this word starts with vowel")
print(word)
https://stackoverflow.com/questions/56209912
复制相似问题