I am trying to print all of the logged-in users tasks from a file(tasks.txt). This is what I have so far but it only prints out one task.
elif choice == "vm":
for task in taskList:
taskItems = task.split(":")
if loginUsername.strip() == taskItems[0].strip():
print(taskItems)
tasks.txt:
Shaun, Admin, Filing, 2020/4/09, 15/4/2020, No
Ashraf, Operations, Quote new air-condition, 2020/3/09, 10/4/2020, No
Clayton, IT, Finish Project, 2020/4/03, 30/4/2020, No
Shaun, Admin, Emails, 2020/4/07, 12/4/2020, No
Shaun, Admin, Data Captures, 2020/4/09, 13/4/2020, No
Roland, Marketing, Marketing Update, 2020/4/01, 10/4/2020, No
Therlow, Sales, Print New Leads, 2020/4/02, 4/4/2020, No
Shaun, Admin, Reply to Lerintha via email, 16/4/2020, 2020/04/15, No
Toni, Deliveries, Deliver all stock, 17/4/2020, 2020/04/16, No
Like SteveK, I assumed that you user name is in the first and the task in the third column:
Produces this output:
Update 1:
Added
tryandexceptto account for invalid linesUpdate 2:
OP is looking for the complete lines from tasks.txt:
Produces this output: