我正在试图创建一个程序,它将输入一个句子和一个单词,并检查该单词的句子并返回单词开头的索引 即Python:获取列表索引
sentence = "random set of words"
word = "of"
result = 9
这是我试过
sentence = (input("Enter a sentence: "))
word = (input("Enter a Word: "))
result = sentence.split()
for x in sentence:
if x == (word):
boom = enumerate(word)
print(boom)
它应该是,对于x在结果:这样就可以得到单个单词每次循环运行。 – pvkcse