In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
Lord Varys, the Master of Whisperers in the realm, has intercepted a secret message written in plain text. To decipher hidden information, he needs to find all occurrences of a specific keyword within this text. The keyword may appear multiple times, and its occurrences can overlap.
Write a function find_all(keyword, text) that given two strings keyword and text, returns a list of all positions in which keyword occurs in text. The positions start at zero.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ |keyword| ≤ 30 | length of keyword | |
1 ≤ |text| ≤ 200 | length of text |
You can also be assured that the word will only be made by lowercase letters and that all letters that appear in text are also in lowercase.
Example Function Calls | Example Output |
print(find_all("stark", "robb stark and sansa stark are stark brothers")) print(find_all("snow", "winter is coming")) print(find_all("ana", "banana ananas")) |
[5, 21, 31] [] [1, 3, 7, 9] |