AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Contact book in python source code12/1/2022
Let's build a main menu that allows users to specify what they want to do. With a GUI or web application, we could add some menu items or buttons, but our command line application is driven only by text input and output on a simple console. updating existing contacts (name or number)īut before we get started on those problems, we need to allow users to choose what kind of functionality they want to activate.searching for names with partial matches. We now have functionality to add and retrieve contacts, and still need to add: If all went well, you'll see the number, as in the example below. #Contact book in python source code codeRun the code again and input the same name as before. However it's good to stay consistent as each of the files is likely to grow in length and complexity over time, and it will be easier to maintain our codebase if our user interaction code is strictly separate from our database interaction code. Our new code to go into contact.py is very simple and it might be tempting to just put this logic directly in the main.py file as it's so short. We need to be able to accept input from the user and show them prompts and output. Let's build the user interaction side first. Allowing the user to add contacts to the phonebook We'll keep the code that interacts with users in our main.py file and the database logic in a new module called contacts.pyĪs we don't have any contacts yet, we'll start by allowing our users to add them.
0 Comments
Read More
Leave a Reply. |