To-Do List App || Python Micro-Project

 To-Do List in Command-Line Using Python


Today we will create a To-Do List in Command-Line using Python Programming Language. It will be best for Micro-Project & to add quality projects to your resume/portfolio. So let me give you an info about this Micro-Project. Here I won't give the full code, but instead, I will give some major block of code and reset of you guys need to create. Take a sneak-peek of how this To-Do List works.

 ðŸ”ŠTurn up Volume 

We will store all the To-Do Items in List i.e we will be using all build-in list function (but we can do it with File Handling that will store data in .txt format), First we will add some basic function like addTask(), displayTask()deleteTask(), etc also we can define more functions if required, but for now we will use only this 3 functions.

  1. addTask() = In this function, we will add the newTask in List with the build-in function listObj.append(). This append()will add a new Task at the end and return no value. Code given below...
def addTask():
    taskList.append(input("Assgin New Task-->"))
    engine.say("New Task Has Been Assgin")
    engine.runAndWait()
    2. displayTask() = In this function, we will display all the Tasks that are store in TaskList         with the help of for loop.
def display():
    print("Task To Be Done")
    engine.say("You need to do all this Task")
    x=0
    for i in taskList:
        x=x+1
        print(f'{x}.{i}')
    engine.runAndWait()
        In the above code, we have used for loop to display the List Items one-by-one.

    3. deleteTask() = In this function, we will delete unwanted / completed tasks from the                TaskList. For deleting tasks from the particular index number we will be using                             pop(index), where index is an integer value of the task you want to delete.
def delete():
    indx = int(input('Input Index number to Delete-->'))
    speak = taskList.pop(indx)+' task has successfully deleted'
    engine.say(speak)
    engine.runAndWait()
These are the functionality of the To-Do List App, now we'll come to the main function from where we'll start to execute/make use of this functionality. For a new user, we'll display a Menu Task where each task will be assigned with a number & we'll ask the user to enter his commands with the number assigned to those functions.
print("""    1. Add In List
    2. Display List
    3. Delete Task
    4. Exit""")
And then we will use the if-else condition to check what the user wants to perform the tasks. If any of the task is chosen by the user then we'll call that function.
if chs == '1':
    add()
if chs == '2':
    display()
if chs == '3':
    delete()
if chs == '4':
    print("Thanks For using command Line App")
    quit()
Here chs is the integer variable that contains the choice of user using input(). And quit() is a pre-defined function to exit from a program that is currently being executed.

Now, to make it continuous we will add a loop i.e while loop will be best here. In this while loop, we will add the if-else conditions with proper indentation. And that's it your code is ready to execute. 

You can add your own idea to this code to make it more advance and user friendly for new users.

Having any problem regarding any programming related stuff, feel free to dm me on my Social Media Handle-->Instagram

Check my Portfolio-->prathmeshchaudhari.me

Subscribe my Blog & comment below !!!



Comments