Simon says

Report a typo

Do you know the game "Simon says"? The instructor, "Simon", says what the players should do, e.g. "jump in the air" or "close your eyes". The players should follow the instructions only if the phrase starts with "Simon says". Now, let's implement a digital version of this game! We will modify it a bit: the correct instructions may not only start but also end with the words "Simon says". But be careful, instructions can be only at the beginning, or at the end, but not in the middle!

Write a function that takes a string with instructions: if it starts or ends with the words "Simon says", your function should return the string "I " plus what you would do: the instructions themselves. Otherwise, return "I won't do it!".

You are NOT supposed to handle input or call your function, just implement it.

To get a substring of a string from its beginning till a specific index, use string[:ind+1]. In this case, the element with the index ind will be included. The other way round, to get a substring from a specific index till the end of the string, use string[ind:]. Do not forget to remove the space that remains before the phrase "Simon says".
So, if you want to get string "make a wish" from "make a wish Simon says", you should use the following construction string[:len("Simon says")+1].

Finally, when writing your code, mind its syntax as the code might be complicated and you might make an error!

Sample Input 1:

make a wish Simon says

Sample Output 1:

I make a wish

Sample Input 2:

go away

Sample Output 2:

I won't do it!
Write a program in Python 3
def what_to_do(instructions):
...
___

Create a free account to access the full topic