Creating a Madlib in Python

If you are a beginner learning python, madlibs are one great way to start a project on. It helps you work with basic python strings.

Let's create one shall we? Of course!

So first off let's set our adjective, verb, noun variables we will request from the user.

adjective = input('adjective: ')
verb = input('verb: ')
noun = input('noun: ')

With that out of the way, let's create a sentence or sentences that will take in the adjective, verb and noun inputs from the user by inserting the variables we have set as shown above into our sentence. To keep things short and straight forward we will just create a short sentence. NB: We will be using f string and not string concatenation or the format method, as it's more of a cleaner choice. So below let's create a sentence and set it to a variable 'sentence'.

sentence = f"Somewhere in {noun}, I had to {verb} until I came across this {adjective} mountain. It 
was {adjective} " \
           f"that i decided not to {verb} again because I gotten so emotional until i dropped dead."

With all that done. Now let's print our sentence after taking inputs from the user.

print(sentence)

Our entire code;

adjective = input('Adjective: ')
verb = input('Verb: ')
noun = input('Noun: ')


sentence = f"Somewhere in {noun}, I had to {verb} until I came across this {adjective} mountain. It was {adjective} " \
           f"that i decided not to {verb} again because I gotten so emotional until i dropped dead."

print(sentence)

If you need assistance with your projects feel free to email me at info@airgad.com or whatsapp Jesse stay safe!