

{"id":84948,"date":"2020-12-26T11:23:17","date_gmt":"2020-12-26T05:53:17","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=84948"},"modified":"2026-06-01T12:39:47","modified_gmt":"2026-06-01T07:09:47","slug":"address-book-in-python","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/","title":{"rendered":"Learn How to Create Address Book in Python"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2548,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1xFD-Ol-Sagfd9PqDkKXVsf5IRVv4oVRf\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601071120\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1xFD-Ol-Sagfd9PqDkKXVsf5IRVv4oVRf\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 16:43:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-04 23:36:25&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-04 23:36:25&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>A contact book or address book is an application that stores the information (name, address, contact no, etc.) of people that you save in it. You can also edit and delete the contact.<\/p>\n<h3>Address Book Python Project<\/h3>\n<p>The objective of this project is to create an Address book using python in which the user can add a new contact, edit and delete existing contact and view all the contact.<\/p>\n<p>In this python project for beginners, the user has to click on a button which functions the user wants to access eg &#8211; To edit a contact, the user has to first select a contact then click on view button then edit the contact and then click on edit button. To add a new contact user has to click on the add button.<\/p>\n<h3>Project prerequisite<\/h3>\n<p>We build the address book project with the help of Tkinter module and basic python concept.<\/p>\n<p>Tkinter is a standard GUI library for rendering graphics<\/p>\n<p>To install the library we use the pip install command in the command prompt:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install tkinter\r\n<\/pre>\n<h3>Download Address Book Python Code<\/h3>\n<p>Please download the source code of address book project: <a href=\"https:\/\/drive.google.com\/file\/d\/1xFD-Ol-Sagfd9PqDkKXVsf5IRVv4oVRf\/view?usp=drive_link\"><strong>Address book source code<\/strong><\/a><\/p>\n<h3>Project File Structure<\/h3>\n<p>These are the step to build a contact book python project:<\/p>\n<ol>\n<li>Importing module<\/li>\n<li>Initializing window<\/li>\n<li>Define buttons<\/li>\n<li>Define functions<\/li>\n<\/ol>\n<p><strong>Let\u2019s start building the project<\/strong><\/p>\n<h4>1. Importing module<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from tkinter import *\r\n<\/pre>\n<p>In this step we import libraries. Here, we need to import tkinter module<\/p>\n<h4>2. Initializing window<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">root = Tk()\r\nroot.geometry('400x400')\r\nroot.config(bg = 'SlateGray3')\r\nroot.resizable(0,0)\r\nroot.title('DataFlair-AddressBook')\r\n\r\ncontactlist = [\r\n    ['Parv Maheswari',  '0176738493'],\r\n    ['David Sharma',  '2684430000'],\r\n    ['Mandish Kabra',   '4338354432'],\r\n    ['Prisha Modi','6834552341'],\r\n    ['Rahul kaushik',   '1234852689'],\r\n    ['Johena Shaa' , '2119876543'],\r\n    ]\r\n\r\nName = StringVar()\r\nNumber = StringVar()\r\n\r\nframe = Frame(root)\r\nframe.pack(side = RIGHT)\r\n\r\nscroll = Scrollbar(frame, orient=VERTICAL)\r\nselect = Listbox(frame, yscrollcommand=scroll.set, height=12)\r\nscroll.config (command=select.yview)\r\nscroll.pack(side=RIGHT, fill=Y)\r\nselect.pack(side=LEFT,  fill=BOTH, expand=1)\r\n<\/pre>\n<ul>\n<li><strong>Tk()<\/strong> use to initialized tkinter<\/li>\n<li><strong>geometry()<\/strong> sets the window width and height<\/li>\n<li><strong>title()<\/strong> used to set window\u2019s tiltle<\/li>\n<li><strong>resizable(0,0)<\/strong> this command stop window to resize<\/li>\n<li><strong>bg<\/strong> use to set the background color of the window<\/li>\n<li>Contacts&#8217; information is stored in <strong>contactlist<\/strong><\/li>\n<li>Frame is like a container that is used to organized widgets<\/li>\n<li>Here Scrollbar widget and Listbox widget is used to allow users to select from many options<\/li>\n<\/ul>\n<h4>3. Define functions<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def Selected():\r\n    return int(select.curselection()[0])\r\n\r\ndef AddContact():\r\n    contactlist.append([Name.get(), Number.get()])\r\n    Select_set()\r\n\r\ndef EDIT():\r\n    contactlist[Selected()] = [Name.get(), Number.get()]\r\n    Select_set()\r\n\r\n\r\ndef DELETE():\r\n    del contactlist[Selected()]\r\n    Select_set()\r\n\r\ndef VIEW():\r\n    NAME, PHONE = contactlist[Selected()]\r\n    Name.set(NAME)\r\n    Number.set(PHONE)\r\n\r\ndef EXIT():\r\n    root.destroy()\r\n\r\ndef RESET():\r\n    Name.set('')\r\n    Number.set('')\r\n\r\ndef Select_set() :\r\n    contactlist.sort()\r\n    select.delete(0,END)\r\n    for name,phone in contactlist :\r\n        select.insert (END, name)\r\nSelect_set()\r\n<\/pre>\n<ul>\n<li><strong>Selected()<\/strong> function used to return selected value<\/li>\n<li><strong>Addcontact()<\/strong> function used to add new contact<\/li>\n<li><strong>EDIT()<\/strong> function will edit existing contact<\/li>\n<li><strong>DELETE()<\/strong> function will delete selected contact<\/li>\n<li><strong>VIEW()<\/strong> function will view selected contact<\/li>\n<li><strong>EXIT()<\/strong> used to destroy mainloop<\/li>\n<li><strong>RESET()<\/strong> will set the name and number field to empty string<\/li>\n<li><strong>Select_set()<\/strong> will sort the manage the contactlist and also used in other functions<\/li>\n<\/ul>\n<h4>4. Define buttons and labels<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Label(root, text = 'NAME', font='arial 12 bold', bg = 'SlateGray3').place(x= 30, y=20)\r\nEntry(root, textvariable = Name).place(x= 100, y=20)\r\n\r\nLabel(root, text = 'PHONE NO.', font='arial 12 bold',bg = 'SlateGray3').place(x= 30, y=70)\r\nEntry(root, textvariable = Number).place(x= 130, y=70)\r\n\r\nButton(root,text=\" ADD\", font='arial 12 bold',bg='SlateGray4', command = AddContact).place(x= 50, y=110)\r\nButton(root,text=\"EDIT\", font='arial 12 bold',bg='SlateGray4',command = EDIT).place(x= 50, y=260)\r\n\r\nButton(root,text=\"DELETE\", font='arial 12 bold',bg='SlateGray4',command = DELETE).place(x= 50, y=210)\r\nButton(root,text=\"VIEW\", font='arial 12 bold',bg='SlateGray4', command = VIEW).place(x= 50, y=160)\r\n\r\nButton(root,text=\"EXIT\", font='arial 12 bold',bg='tomato', command = EXIT).place(x= 300, y=320)\r\nButton(root,text=\"RESET\", font='arial 12 bold',bg='SlateGray4', command = RESET).place(x= 50, y=310)\r\n\r\nroot.mainloop()\r\n<\/pre>\n<ul>\n<li><strong>Label()<\/strong> widget used when we want to display text<\/li>\n<li><strong>Entry()<\/strong> widget used when we want to create an input text field.<\/li>\n<li><strong>Button()<\/strong> widget used to display button\n<ul>\n<li><strong>root<\/strong> is the name of our window<\/li>\n<li><strong>text<\/strong> which display on the label as title of that label<\/li>\n<li><strong>font<\/strong> in which form the text will be write<\/li>\n<li><strong>textvariable<\/strong> used to retrieve the text to entry widget<\/li>\n<li><strong>place()<\/strong> \u2013 place widgets at specific position<\/li>\n<li><strong>command<\/strong> called the specific function when the button will clicked<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Project Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84953\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output.png\" alt=\"address book output\" width=\"1366\" height=\"728\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-300x160.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-1024x546.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-150x80.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-768x409.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-720x384.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-520x277.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-output-320x171.png 320w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>We successfully develop the Address book in python. We use tkinter library for rendering graphics. We use a random library to generate random choices.<\/p>\n<p>We learn how to create buttons widget and also learn how to call the function using buttons. In this way, we created Address book project using python. I hope you enjoyed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A contact book or address book is an application that stores the information (name, address, contact no, etc.) of people that you save in it. You can also edit and delete the contact. Address&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":84954,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[23659,23660,21082,22734,21099],"class_list":["post-84948","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-address-book","tag-address-book-in-python","tag-python-project","tag-python-project-for-beginners","tag-python-project-with-source-code"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Learn How to Create Address Book in Python - DataFlair<\/title>\n<meta name=\"description\" content=\"Address book in python with source code. Developed address book with basic python concepts and tkinter library to render graphics\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/address-book-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn How to Create Address Book in Python - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Address book in python with source code. Developed address book with basic python concepts and tkinter library to render graphics\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/address-book-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-26T05:53:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T07:09:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learn How to Create Address Book in Python - DataFlair","description":"Address book in python with source code. Developed address book with basic python concepts and tkinter library to render graphics","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Learn How to Create Address Book in Python - DataFlair","og_description":"Address book in python with source code. Developed address book with basic python concepts and tkinter library to render graphics","og_url":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-12-26T05:53:17+00:00","article_modified_time":"2026-06-01T07:09:47+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"Learn How to Create Address Book in Python","datePublished":"2020-12-26T05:53:17+00:00","dateModified":"2026-06-01T07:09:47+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/"},"wordCount":518,"commentCount":8,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg","keywords":["address book","address book in python","Python project","python project for beginners","python project with source code"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/address-book-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/","url":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/","name":"Learn How to Create Address Book in Python - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg","datePublished":"2020-12-26T05:53:17+00:00","dateModified":"2026-06-01T07:09:47+00:00","description":"Address book in python with source code. Developed address book with basic python concepts and tkinter library to render graphics","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/address-book-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/12\/address-book-in-python-project.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/address-book-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Learn How to Create Address Book in Python"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/84948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=84948"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/84948\/revisions"}],"predecessor-version":[{"id":148625,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/84948\/revisions\/148625"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/84954"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=84948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=84948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=84948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}