Starting from a list like this:
words = [\'tree\', \'water\', \'dog\', \'soap\', \'bike\', \'cat\', \'bird\']
I want to get the sublist bet
This can be accomplished with the .index() method of lists, and with the slice notation..
.index()
words = ['tree', 'water', 'dog', 'soap', 'cat', 'bird'] start_index = words.index(start_word) end_index = words.index(end_word) sublist = words[start_index:end_index+1]