I am newbie to python coding and need your expertise help in my below issue, Currently I am trying to read data from a txt file and process further once its moved to a list.
Below is my code:
case 'add':
todo = input("enter a todo")+"\n"
file = open('data.txt','r')
todos =file.readlines()
file.close()
todos.append(todo)
file = open('data.txt','w')
file.writelines(todos)
file.close()
Error I'm getting (please note both my main.py and data.txt are in the same folder)
file = open('data.txt','r')
^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'data.txt'