Quantcast
Viewing latest article 3
Browse Latest Browse All 3

Python: Getting the Index of a list

I'm trying to create a program that will take input of a sentence and a word and check that sentence for the word and return the index of the beginning of the wordi.e.

sentence = "random set of words"     word = "of"     result = 9

This is what I tried

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)

Viewing latest article 3
Browse Latest Browse All 3

Trending Articles