0

I need to get my program to identify a word in a string and give it its index e.g. Hello, world, world if i input world would give me "world 1st positions world 2nd position. I have converted string to list and used enumerate, i can index whole string etc its just can't get program to give indexes of same word which is in the same text .

def quote():
   quote = " sample quote sample quote sample quote"
   quote1 = quote.split()
   print(str(quote1) + "\n\n");
   word = input("what word would you like to index? ")
   print(quote1.index(word ));
   print("The word you have chosen is placed at index " +
      str(quote1.index(word)))

As you can see quite new to all this have been trying all day!!

srowe
  • 1

0 Answers0