• Home
  • Get Started
  • Updates
  • Support
  • Shop
  • Pricing
  • AI News
Get Started
  • Login
  • Register
Neuraldemy
Cart / 0.00$

No products in the cart.

No Result
View All Result
Get Started
Neuraldemy
Get started
Home Free

Create A To-Do-List App In Python: Complete Tutorial

Amritesh Kumar by Amritesh Kumar
November 30, 2023 - Updated on August 1, 2024
in Python, Free
Reading Time: 7 mins read
A A
Create A To-Do-List App In Python

In this tutorial you will learn how to create a to-do-list app in Python is really an interesting project idea. I have created one such project. Please check out the code below and see if you can create it on your own. Make sure you are familiar with OOP in Python before you start. Please note this project also covers errors and exception handling so if you are a beginner make sure to practice simple projects first.

What You Will Learn:

  1. Allow users to create, manage and delete tasks.
  2. Learn how to give users an amazing user experience
  3. Update and mark a task to a certain status

Please make sure to code along to learn faster. You can’t copy the site content due to security purposes. Make sure to use laptop or desktop for better user experience.


class Task():
    
    """This program allows you manage your to-do list and is fully 
    tested from the point of view of users. 
    It's also very user friendly"""
    
    
    def __init__(self):
        
        self.tasks = []
        self.active_tasks = []
        self.completed_tasks = []
        
        
    # allow users to find help 
    def app_help(self):
        
        print("""You can use this app to create to-do-lists and manage your tasks:\n
                          - use create_task() to create new tasks\n
                          - delete_task() to delete a single task \n
                          - delete_all_tasks() to delete all task from your main list\n
                          - create_active_tasks() to create an active task list\n
                          - create_completed_tasks() to mark a single task as complete\n
                          - all_tasks_completed() to mark all as complete\n
                          - delete_completed_tasks() deletes everything in completed list\n
                          - show_status() shows status of all tasks""")
        
        
    # allow users to create tasks
    def create_task(self):
        
        while True:
            
            new_tasks = input('Enter new tasks or Q or q to quit:\n')
            
            if new_tasks == "Q" or new_tasks == 'q':
                break 
                
            elif new_tasks == '':
                print("Please add a task!!")
                continue
                
            else:
                self.tasks.append(new_tasks)
                
                if len(self.tasks) != 0:
                    print("\n")
                    print(f"Your Tasks are:{self.tasks}")
                    
    
    # allow users to delete a single task from main list
    def delete_task(self):
        
        if len(self.tasks) == 0:
            
            print("You don't have anything in your task list")
        
        else:
            while True:
                
                delete_task = input('Enter the task number to be deleted or Q/q to quit:')
                
                if delete_task == 'q' or delete_task == 'Q':
                    break
                else:
                    try:
                        try:
                            self.tasks.pop(int(delete_task))
                            print("Task Deleted\n")
                            print(f"Your Tasks are:{list(enumerate(self.tasks))}")
                            if len(self.tasks) == 0:
                                print("You don't have any pending tasks")
                                break 
                        except IndexError:
                            print("Please enter the number within task length range")
                        
                    except ValueError:
                        print("Please enter either task number or q/Q")
    
    # Allow users to delete all tasks from main and active lists
    def delete_all_tasks(self):
        
        if len(self.tasks) != 0:
            self.tasks.clear()
            self.active_tasks.clear()
            print("All tasks are clear")
            
        else:
            print("You don't have any task in your list")
            
    # allow users to create active tasks
    def create_active_tasks(self):
        
        if len(self.tasks) !=0: 
            self.active_tasks = self.tasks[:]
            print(f"Your active tasks are:{self.active_tasks}")
            
        else:
            print("You don't have any task in tasks list")
            
            while True:
                new_task_input = input("Want to create new tasks?:yes or no").lower()
                
                if new_task_input == "yes":
                    self.create_task()
                    break
                if new_task_input == "no":
                    break
                if new_task_input not in ["yes", "no"]:
                    print("Please enter either yes or no")
                
    # allow users to mark a task as complete
    def create_completed_tasks(self):
        
        if len(self.active_tasks) == 0:
            print("You don't have anything in your active task list")
        
        else:
            
            while True:
                
                completed_input = input("Enter task number to mark as complete or Q/q to quit")
                
                if completed_input == 'Q' or completed_input == 'q':
                    break
                    
                else:
                    try:
                        try:
                            popped_task = self.active_tasks.pop(int(completed_input))
                            self.tasks.remove(popped_task)
                            self.completed_tasks.append(popped_task)
                            
                            print("\n")
                            print(f"Your completed tasks are: {self.completed_tasks}\n")
                            
                            if len(self.active_tasks) == 0:
                                print("Great Job 🎉 All Done!!")
                                break
                            else:
                                print(f"Your active tasks are:{list(enumerate(self.active_tasks))}")
                                
                        except IndexError:
                            print("Please enter number within task range")
                            
                    except ValueError:
                        print("Please enter either task number or Q/q")
                        
    # allow users to mark all tasks as completed
    def all_tasks_completed(self):
        
        if len(self.active_tasks) == 0:
            print("You don't have anything in your active task list")
        else:
            self.completed_tasks = self.active_tasks[:]
            print(f"Your completed tasks are: {list(enumerate(self.completed_tasks))}\n")
            
        
    # to delete all completed tasks
    def delete_completed_tasks(self):
        
        if len(self.completed_tasks) == 0:
            
            print("There is nothing to delete")
        else:
            self.completed_tasks.clear()
            
            print("Completed tasks are deleted")
            
    # allow users to see all task list status
    def show_status(self):
        
        print("Here is the detail of your task lists:\n")
        
        if len(self.tasks) == 0:
            print("Your task list: All Done 🥰 \n")
        else:
            print(f"Your task list:{self.tasks}\n")
        
        if len(self.active_tasks) == 0:
            print("Your active tasks are: All Done 🥰 \n")
        else:
            print(f"Your active tasks are: {self.active_tasks}\n")
            
        if len(self.completed_tasks) == 0:
            print(f"Your completed tasks are: All Done 🥰 \n")
        else:
            print(f"Your completed tasks are: {self.completed_tasks}\n")
Code language: Python (python)

That’s all. Hope this was helpful. Now it’s time to create a notes app. Check it out from here.

Tags: Python ProjectsPython Tutorial
Previous Post

Notes App In Python: Complete Tutorial

Next Post

Why AI Won’t Replace Your Jobs!!

Amritesh Kumar

Amritesh Kumar

I believe you are not dumb or unintelligent; you just never had someone who could simplify the concepts you struggled to understand. My goal here is to simplify AI for all. Please help me improve this platform by contributing your knowledge on machine learning and data science, or help me improve current tutorials. I want to keep all the resources free except for support and certifications. Email me @amriteshkr18@gmail.com.

Related Posts

pickle module in python

Pickle Module In Python: A Comprehensive Guide for Beginners

Python Os Module

Python OS Module: A Comprehensive Guide for Beginners

Install Miniconda on Windows (The EASIEST Way! )

TensorFlow Simplified Guide For Beginners

Notes App In Python: Complete Tutorial

E-commerce App In Python – User Facing

Next Post
Why AI Won’t Replace Your Jobs!!

Why AI Won’t Replace Your Jobs!!

AI & Jobs: Understanding How Things May Actually Happen

AI & Jobs: Understanding How Things May Actually Happen

Intelligence, Knowledge, Data, Information, AGI, Superintelligence And Responsible AI

Intelligence, Knowledge, Data, Information, AGI, Superintelligence And Responsible AI

  • Customer Support
  • Get Started
  • Ask Your ML Queries
  • Contact
  • Privacy Policy
  • Terms Of Use
Neuraldemy

© 2024 - A learning platform by Odist Magazine

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

*By registering into our website, you agree to the Terms & Conditions and Privacy Policy.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Home
  • Get Started
  • Updates
  • Support
  • Shop
  • Pricing
  • AI News
  • Login
  • Sign Up
  • Cart
Order Details

© 2024 - A learning platform by Odist Magazine

This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
0