top of page

Data Scientist Program


Free Online Data Science Training for Complete Beginners.

No prior coding knowledge required!

Acronym generator using Python

An acronym generator generates a word from a phrase using keyword abbreviations. Individual letters from the words contained in a phrase are used to create a new word, which we refer to as acronym.

How an acronym generator works?

An Acronym Generator will take a String as an input and it will return the initials of all the words in the String.

How to build an acronym generator?

Step 1

To begin with , we need a phrase or word from the user. We can do that using input() method.

user_input = input("Enter a phrase: ")

We have stored the user input in a user_input variable.

Step 2

Now that we have stored our user input, we must ignore words like 'of' , 'and' from the user input as most of the time, these words are not considered for acronyms.

Also, we need to separate each word and store it individually in a form of a list so that we can easily iterate through it.

phrase =(user_input.replace('of','')).replace('and','').split()

In the user_input.replace() , we are using .replace() function to ignore 'of' and 'and' from the input, if any.

Then we are using .split() function to break down the string into individual words and store them as a list in phrase variable.

Step 3

We need an empty string variable to store our acronym. Let's quickly create one.

acronym = ""

Step 4

Now let's create a for loop which will help iterate through the phrase variable

for word in phrase:
    acronym = acronym + word[0].upper()

In acronym = acronym + word[0], we are slicing off the first letter of words stored in phrase using slicing operator and adding it to our acronym variable.

We are also using .upper() function to capitalize the acronyms.

Step 5

Lastly, just add a print statement which will print out the acronym as our output.

print("The acronym of " + " " + user_input + " " + "is" + " :" + " " + acronym)


Recent Posts

See All


Sep 13, 2021

why just ignore <<and>> and <<of>>. There are not other word to ignore ?

Data Insight
Data Insight
Sep 13, 2021
Replying to

Many prepositions are 2 letter words. Perhaps you can ignore all 2-letter words.


Data Insight
Data Insight
Sep 13, 2021

Very nice! But didn't give an example of using your code.

bottom of page