Next word list X26242


Statement
 

pdf   zip

thehtml

Write a function next_word_list(w, f) that given a nonempty string w and a list of strings f, returns the list formed by the strings in f that appear just after each ocurrence of w in f. The order of appearance of the words in the resulting lists must preserve the original order.

Sample session
>>> next_word_list('red', ['red','yellow','red','black','grey','red'])
['yellow', 'black']
>>> next_word_list('big', ['small','big'])
[]
>>> next_word_list('big' , ['big','small'])
['small']
>>> next_word_list('blue', ['green'])
[]
>>> next_word_list('blue', [])
[]
>>> next_word_list('red', ['red','red','red'])
['red', 'red']
Information
Author
Language
English
Official solutions
Python
User solutions
Python