r/PythonLearning 16h ago

Building Todo list with python....with multi_files...

A modular, multi-page Command Line Interface (CLI) To-Do application built using Python. Designed with clean code practices, this project separates application logic across multiple files and implements file handling for persistent data storage.

#File:- (todo.py)

from todo import Todo
my_todo = Todo()
while True:
    user_choice = input("Enter 1 to add_task,2 to show_task,3 to exit: ")
    if (user_choice == "1"):
        my_todo.add_task()
    elif(user_choice == "2"):
        my_todo.show_task()
    elif(user_choice == "3"):
        break
    else:
       print("print only 1,2,and 3:--")



# File:-(loop.py)
import loop_py
class Todo():
    def __init__(self):
        self.tasks = []
        self.completed_tasks = "tasks.txt"
        
    def add_task(self):
        new_task = input("Enter some task:")
        self.tasks.append(new_task)
        with open("Data_base.txt","a") as f:
            result = f.write(new_task + "\n")
            print("Data successfully saved")
            f.close
    def show_task(self):
        if (not self.tasks):
            print("your list is emptied")
        else:
            for i,task in enumerate(self.tasks):
                print(i + 1, task)

Completed a multi-page To-Do app in Python with persistent file storage! 🐍 Now that I've mastered core Python basics and modular structure, my next goal is diving into FastAPI, relational databases (PostgreSQL), and building production-ready Backend APIs(Give me your feedback that what I do now.....)
6 Upvotes

Duplicates