【发布时间】:2019-12-10 02:10:17
【问题描述】:
我想标题是不言自明的,不过,我会让自己更清楚。
我必须找到字符串中每个字符的索引。例如,
word = "banana"
def indexes(x, word):
#some code
return (list of indexes of x character in the word)
输出:
indexes('a', word)
>> [1, 3, 5]
我如何得到这个结果?
【问题讨论】:
标签: python string list indexing