Creating a Todo List - Python

 

Introduction

Ever felt like your tasks are running wild and you can't keep track of them?  No worries! Let’s build a simple yet powerful todo list using Python to keep everything organized! 

1. Simple Console-Based Todo List

Let's start with a basic console-based todo list that allows you to add, view, and remove tasks.

# Simple Todo List in Python

todo_list = []

def show_tasks():
    if not todo_list:
        print("No tasks yet! Add some.")
    else:
        print("Your Todo List:")
        for i, task in enumerate(todo_list, 1):
            print(f"{i}. {task}")

def add_task():
    task = input("Enter a task: ")
    todo_list.append(task)
    print(f"Added: {task}")

def remove_task():
    show_tasks()
    try:
        task_num = int(input("Enter task number to remove: "))
        removed_task = todo_list.pop(task_num - 1)
        print(f"Removed: {removed_task}")
    except (IndexError, ValueError):
        print("Invalid input! Try again.")

def main():
    while True:
        print("\nOptions: 1) Add  2) View  3) Remove  4) Exit")
        choice = input("Choose an option: ")
        if choice == '1':
            add_task()
        elif choice == '2':
            show_tasks()
        elif choice == '3':
            remove_task()
        elif choice == '4':
            print("Goodbye!")
            break
        else:
            print("Invalid choice! Try again.")

main()

Boom! You now have a working todo list in Python!

2. Adding a Fun Factor

Want to make your todo list more fun? Add motivational messages and emojis! 

import random

motivational_quotes = [
    "Great job! Keep going!",
    "One task at a time!",
    "You're unstoppable!",
]

def add_task():
    task = input("Enter a task: ")
    todo_list.append(task)
    print(f"Added: {task} {random.choice(motivational_quotes)}")

Now, every time you add a task, you get a boost of motivation!

3. Expanding Features

Want to go even further? Here are some bonus ideas:

  • Add a GUI version using Tkinter
  • Save tasks to a file so they persist after closing the program
  • Set reminders with Python’s time or schedule module 

Try expanding the todo list and making it even more useful! 

Conclusion

Building a todo list in Python is easy, fun, and useful!  Now, no more forgetting important tasks! 

Happy coding! 

 

Post a Comment

0 Comments