Question: I need help taking a list that could be 1 0 0 0 characters long or more, up to n . For example [ '

I need help taking a list that could be 1000 characters long or more, up to n.
For example ['the', 'this', 'john', 'jake', 'apple', 'orange', 'grapes', 'rake', 'car', 'bike', 'lawn', 'state', 'fork', 'spoon', 'insurance', 'agent', 'university', ''forward', 'ahead', 'support', 'education', 'always', 'stay', 'go', 'truck', 'tips', 'there', 'decisive']
With this list, i need help creating a function that takes in n which can be any number and display a list that displays a tuple of words prior to that word.
That is, if i display n =5 and a word 'ahead', i would expect to see
('spoon', 'insurance', 'agent', 'university', 'forwaord').
If the word 'ahead' appears more than once, it will look for that word and display the previous n words as a tuple

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!