我已经从一个字符串创建了所有子字符串,现在我想将所有以'aeiou'开头的子字符串存储到一个空列表中。你可以检查错误吗?

string ='shivraj'
i=0
j=0
a=[]                                      //storing the sub strings into empty list
for i in range(len(string)):               //for loop to create sub strings 
    for j in range(i,len(string)):               
        a.append((string[i:j+1]))
        j=j+1
    i=i+1
s=[]                          //empty list to store sub strings starting with vowel
k=0
l=0
for x in range(0,len(a)):               //loop to run for entire sub string list
    if a[k][l] in 'aeiou':              // [l] to extract first letter of sub string and match it 
       s.append(a[k])                      with 'aeiou' and store it in s=[] if matched.       
       k=k+1                            // to increment for next index values

运行整个代码后,我的输出显示为空列表(s = []),您能帮我得到错误吗?

评论