I need to write a function that will take a string as an argument and gives the description of the string as output. So when i insert the following string in my function:
"12:30 – 13:00 Red Light Radio – Ovational Exercises"
The output should be:
"Red Light Radio – Ovational Exercises"
I know i can get rid of all the spaces by using .strip() but i can't figure out how to split the sentence between the date and the description. I use regular expressions to find the time so i can split the sentence at the last index of the time but it is not fully working
My current code:
def extract_activity(string):
time_expressions=re.findall(r'[\d.:]+.*[\d.:]+', string)[0]
string.split(time_expressions[-1])
return string
test = "12:30 – 13:00 Red Light Radio – Ovational Exercises"
extract_activity(test)
I want "Red Light Radio – Ovational Exercises" as result but my split command is not working. The split command should split the string up into 2 strings one containing the time and the other one containing the letters, after that i should use .strip() to get rid of all the spaces.
All help will be appreciated