def indexes(word, letter):
acc=[]
for i in word:
for g in letter:
if g in
i:
acc.append(word.index(i))
return
acc
if i call the
function indexes("mississippi","s")
the following is
returned:
[2, 2, 2,
2]
So, the function
returns the correct amount of letters, but it only returns the first index of where
"s
" is found and fills the list with that index. Any reason why
the list doesn't return the index of each
"s
"?
No comments:
Post a Comment