Python ā File Handling
Hello, I need help with file handling in python. Let's assume I have 2 function: add() And dela() First function is responsible for adding new task to the file. Second function is responsible for deleting task from a file. The code for these is shown here: https://code.sololearn.com/ciPtSPmRXjG5/?ref=app When user uses add() function, the text will be added in the following format: "Task *number* : *user input* " This works indeed. When user uses dela() function, the program will delete the task with the specified task number from the user input. So it will read lines, and loop through them to see if user input is present. However, when task is deleted, the order in which tasks are numbered breaks down. If test.txt file looks like this: #reserved line Task 1 : Make this program Task 2 : Make another program Task 3 : Learn this If I delete task 2, and add another task, test.txt will look like this: #reserved line Task 1 : Make this program Task 3 : Learn This Task 3 : Added task