Every week, my school makes us type which assignments we will be doing for the week. I want to do this automatically with python.
Below is a example of what an input I might want the program to take.
Unit 1 presentation - Due in 2 days - 40 minutes spent
English Unit 2 Test - Due in 3 days - 1 hour spent
History Essay - Due in 7 days - 10 minutes spent
I want to get rid of everything other than the name of the assigments. How can I achieve this? I can't simply use the find() method since the substrings may vary.
Google hasn't been much help. I'm a beginner, so please bear with me.
CodePudding user response:
I would try to take each line as line
and process as
assignment_name = line.split("-")[0].strip()