-65
这是我的代码:如何找到一个单词的所有出现的所有指标中的字符串
sentence = input("Give me a sentence ")
word = input("What word would you like to find ")
sentence_split = sentence.split()
if word in sentence_split:
print("have found",word,)
print("The word comes in the position")
else:
print("error have not found",word)
wordfound = (sentence_split.index(word)+1)
print(wordfound)
我能够得到第一发生在串词的索引。我怎样才能得到全部的发生?
纯代码编写请求是题外话堆栈溢出 - 我们希望有关问题在这里以*特定*编程问题 - 但我们会很乐意帮助你自己写!告诉我们[您尝试过的](http://whathaveyoutried.com),以及您卡在哪里。这也将帮助我们更好地回答你的问题。 – Cerbrus
@GeorgeStocker:虽然我可以理解它不应该被删除,但这是一个教科书的代码请求的情况下... – Cerbrus
@Cerbrus我还没有找到一个关于“纯代码写入请求”的关闭理由脱离主题;事实上,如果他们不要求太多,我们可以明确地与他们联系:http://meta.stackexchange.com/a/224104/16587 –