Next word list X26242


Statement
 

pdf   zip

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

Sample session

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