

{"id":83161,"date":"2020-09-24T09:30:01","date_gmt":"2020-09-24T04:00:01","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=83161"},"modified":"2026-06-01T12:12:25","modified_gmt":"2026-06-01T06:42:25","slug":"python-mad-libs-generator-game","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/","title":{"rendered":"Python Mad Libs Generator Game"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2520,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1TloS5eX3Px2_GTW69N4eTx9K-XY9ipPs\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601064335\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1TloS5eX3Px2_GTW69N4eTx9K-XY9ipPs\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-01 14:57:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 01:28:15&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-08 02:51:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-11 04:55:30&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-11 04:55:30&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Mad libs generator is a fun game that is usually played by kids.<\/p>\n<p>In this python game user has to enter substitutes for blanks in the story without knowing the story. It will be fun to read aloud the stories after filling the blanks.<\/p>\n<h3>Python\u00a0Mad Libs Generator<\/h3>\n<p>The objective of this project is to develop a Mad Libs Generator python project. In this project, the user first has to pick a story by the title of the story. Then the user has to enter specific words like a noun, adverb, verb, food, adjective, etc, according to the requirements. And then the story will be generated.<\/p>\n<p>This is a python project for absolute beginners and is developed using the basic concept of python and tkinter.<\/p>\n<h2>Steps to develop Mad Libs Generator Game<\/h2>\n<h3>Project Prerequisites<\/h3>\n<p>Tkinter is a GUI Python library used to build GUI applications in the fastest and easiest way. To install the library, you can use the pip install command in command line:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install tkinter\r\n<\/pre>\n<h3>Download Python Mad Libs Generator Code<\/h3>\n<p>Please download the source code of mad libs generator project: <a href=\"https:\/\/drive.google.com\/file\/d\/1TloS5eX3Px2_GTW69N4eTx9K-XY9ipPs\/view?usp=drive_link\"><strong>Python Mad Libs Generator<\/strong><\/a><\/p>\n<h3>Project File Structure<\/h3>\n<p>These are the required steps to build Mad Libs generator python project:<\/p>\n<ul>\n<li>Import modules<\/li>\n<li>Create a display window<\/li>\n<li>Define functions<\/li>\n<li>Create buttons<\/li>\n<\/ul>\n<h4>1. Import Modules<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">from tkinter import *\r\n<\/pre>\n<p>The first step to build a project is to import the required modules. In this project, we import tkinter module.<\/p>\n<h4>2. Create a Display Window<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">root = Tk()\r\nroot.geometry('300x300')\r\nroot.title('DataFlair-Mad Libs Generator')\r\nLabel(root, text= 'Mad Libs Generator \\n Have Fun!' , font = 'arial 20 bold').pack()\r\nLabel(root, text = 'Click Any One :', font = 'arial 15 bold').place(x=40, y=80)\r\n<\/pre>\n<ul>\n<li><strong>Tk()<\/strong> initialized tkinter which means window created<\/li>\n<li><strong>geometry()<\/strong> used when we want to set the width and height of the window<\/li>\n<li><strong>title()<\/strong> used to give the title of the window<\/li>\n<li><strong>Label()<\/strong> widget use to display text that users can\u2019t able to modify<\/li>\n<li><strong>root<\/strong> is the name which we give to our window<\/li>\n<li><strong>text<\/strong> takes the text we want to display on the label<\/li>\n<li><strong>font<\/strong> used to set the size and type of fonts<\/li>\n<li><strong>pack<\/strong> organized widget in block<\/li>\n<li><strong>place()<\/strong> used when we want to place widgets in a specific position<\/li>\n<\/ul>\n<h4>3. Define Function<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def madlib1():\r\n\r\n    animals= input('enter a animal name : ')\r\n    profession = input('enter a profession name: ')\r\n    cloth = input('enter a piece of cloth name: ')\r\n    things = input('enter a thing name: ')\r\n    name= input('enter a name: ')\r\n    place = input('enter a place name: ')\r\n    verb = input('enter a verb in ing form: ')\r\n    food = input('food name: ')\r\n    print('say ' + food + ', the photographer said as the camera flashed! ' + name + ' and I had gone to ' + place +' to get our photos taken on my birthday. The first photo we really wanted was a picture of us dressed as ' + animals + ' pretending to be a ' + profession + '. when we saw the second photo, it was exactly what I wanted. We both looked like ' + things + ' wearing ' + cloth + ' and ' + verb + ' --exactly what I had in mind')\r\n\r\n\r\ndef madlib2():\r\n   \r\n    adjactive = input('enter adjective : ')\r\n    color = input('enter a color name : ')\r\n    thing = input('enter a thing name :')\r\n    place = input('enter a place name : ')\r\n    person= input('enter a person name : ')\r\n    adjactive1 = input('enter a adjactive : ')\r\n    insect= input('enter a insect name : ')\r\n    food = input('enter a food name : ')\r\n    verb = input('enter a verb name : ')\r\n\r\n    print('Last night I dreamed I was a ' +adjactive+ ' butterfly with ' + color+ ' splocthes that looked like '+thing+ ' .I flew to ' + place+ ' with my bestfriend and '+person+ ' who was a '+adjactive1+ ' ' +insect +' .We ate some ' +food+ ' when we got there and then decided to '+verb+ ' and the dream ended when I said-- lets ' +verb+ '.')\r\n\r\n\r\ndef madlib3():\r\n\r\n    person = input('enter person name: ')\r\n    color = input('enter color : ')\r\n    foods = input('enter food name : ')\r\n    adjective = input('enter aa adjective name: ')\r\n    thing = input('enter a thing name : ')\r\n    place = input('enter place : ')\r\n    verb = input('enter verb : ')\r\n    adverb = input('enter adverb : ')\r\n    food = input('enter food name: ')\r\n    things = input('enter a thing name : ')\r\n   \r\n    print('Today we picked apple from '+person+ \"'s Orchard. I had no idea there were so many different varieties of apples. I ate \" +color+ ' apples straight off the tree that tested like '+foods+ '. Then there was a '+adjective+ ' apple that looked like a ' + thing + '.When our bag were full, we went on a free hay ride to '+place+ ' and back. It ended at a hay pile where we got to ' +verb+ ' ' +adverb+ '. I can hardly wait to get home and cook with the apples. We are going to make appple '+food+ ' and '+things+' pies!.')  \r\n<\/pre>\n<ul>\n<li><strong>input(<\/strong>) field takes the input from the user<\/li>\n<li><strong>print()<\/strong> will print the text given in it.<\/li>\n<\/ul>\n<h4>4. Define Buttons<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Button(root, text= 'The Photographer', font ='arial 15', command= madlib1, bg = 'ghost white').place(x=60, y=120)\r\nButton(root, text= 'apple and apple', font ='arial 15', command = madlib3 , bg = 'ghost white').place(x=70, y=180)\r\nButton(root, text= 'The Butterfly', font ='arial 15', command = madlib2, bg = 'ghost white').place(x=80, y=240)\r\n\r\nroot.mainloop()\r\n<\/pre>\n<p><strong>Button()<\/strong> widget used to display buttons on our tkinter window<\/p>\n<p>command is called when the button is click and it is used to call the function<\/p>\n<p><strong>root.mainloop()<\/strong> used when we want to run our program<\/p>\n<h4>Mad Libs Generator Game Output<\/h4>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-83164\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output.png\" alt=\"mad libs generator output\" width=\"1366\" height=\"708\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output.png 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-300x155.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-1024x531.png 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-150x78.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-768x398.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-720x373.png 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-520x270.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/mad-libs-generator-output-320x166.png 320w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>We have successfully developed the mad libs generator python project. We used tkinter library for rendering graphics on a display window and learn how to create buttons widget and pass the function to the button. In this way, we build this python project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mad libs generator is a fun game that is usually played by kids. In this python game user has to enter substitutes for blanks in the story without knowing the story. It will be&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":83165,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[23363,21082,22734],"class_list":["post-83161","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-mad-libs-generator","tag-python-project","tag-python-project-for-beginners"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Mad Libs Generator Game - DataFlair<\/title>\n<meta name=\"description\" content=\"Python Mad Libs Generator - In this python game user has to enter substitutes for blanks in the story without knowing the story. This is developed using basic concept of python &amp; tkinter.\" \/>\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\/python-mad-libs-generator-game\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Mad Libs Generator Game - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python Mad Libs Generator - In this python game user has to enter substitutes for blanks in the story without knowing the story. This is developed using basic concept of python &amp; tkinter.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/\" \/>\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-09-24T04:00:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T06:42:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.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":"Python Mad Libs Generator Game - DataFlair","description":"Python Mad Libs Generator - In this python game user has to enter substitutes for blanks in the story without knowing the story. This is developed using basic concept of python & tkinter.","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\/python-mad-libs-generator-game\/","og_locale":"en_US","og_type":"article","og_title":"Python Mad Libs Generator Game - DataFlair","og_description":"Python Mad Libs Generator - In this python game user has to enter substitutes for blanks in the story without knowing the story. This is developed using basic concept of python & tkinter.","og_url":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-09-24T04:00:01+00:00","article_modified_time":"2026-06-01T06:42:25+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.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\/python-mad-libs-generator-game\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Mad Libs Generator Game","datePublished":"2020-09-24T04:00:01+00:00","dateModified":"2026-06-01T06:42:25+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/"},"wordCount":437,"commentCount":23,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.jpg","keywords":["mad libs generator","Python project","python project for beginners"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/","url":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/","name":"Python Mad Libs Generator Game - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.jpg","datePublished":"2020-09-24T04:00:01+00:00","dateModified":"2026-06-01T06:42:25+00:00","description":"Python Mad Libs Generator - In this python game user has to enter substitutes for blanks in the story without knowing the story. This is developed using basic concept of python & tkinter.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/09\/python-mad-libs-generator-game.jpg","width":1200,"height":628,"caption":"python mad libs generator game"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-mad-libs-generator-game\/#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":"Python Mad Libs Generator Game"}]},{"@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\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/83161","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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=83161"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/83161\/revisions"}],"predecessor-version":[{"id":148591,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/83161\/revisions\/148591"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/83165"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=83161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=83161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=83161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}