I have a problem. I have a string like this: "Can you please turn off the lights?". Now I want to split the sentence like this:
['can', 'you', 'please', 'turn', 'off', 'the', 'lights?']
But now I also want to remove the ?
at the end. I know I could just use substr
but the expressions are not always available. How can I detecet them and if they are present remove them from a sentence?
Here is my code now:
given_command = "Can you please turn off the lights?"
data = given_command.lower().split(" ")
print(data)