to do list in python

To create a to-do list in Python, you can use a combination of loops, user input, and lists. Here's a simple example of how you can do it:

main.py
# Create an empty list to store the to-do items
todo_list = []

# Prompt the user for input until they enter "quit"
while True:
    # Prompt the user to enter a to-do item
    todo_item = input("Enter a to-do item (or 'quit' to exit): ")

    # If the user enters "quit", break out of the loop
    if todo_item == "quit":
        break

    # Add the item to the to-do list
    todo_list.append(todo_item)

# Print the final to-do list
print("To-Do List:")
for item in todo_list:
    print("- " + item)
503 chars
20 lines

In this example, we use a while loop to continuously prompt the user for input until they enter "quit". Each to-do item entered by the user is added to the todo_list using the append() method.

Finally, we use a for loop to iterate over the todo_list and print each item with a bullet point.

Feel free to modify this example to suit your needs or to add more functionality to your to-do list.

related categories

gistlibby LogSnag