top of page

Data Scientist Program


Free Online Data Science Training for Complete Beginners.

No prior coding knowledge required!

Acronym generator from words or phrases

Generally, an acronym generator will take as an input a string and will return all the first elements of words in the string as an uppercase.

The first thing to do is asking the user to enter a phrase using input() method in python 
user_input = input("Enter a phrase: ")

We have now store the phase into our variable user_input. After that, we are going to separate each word and store in a list such that we can easily iterate through. The list is assign to the variable phrase

phrase = user_input.split()

Now we need to create our variable acronym as an empty string.

acronym = ""

By using a for loop, we will loop our new variable word through our list phrase.

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

With acronym + word[0] we are slicing and assigning to our variable acronym which is at the beginning an empty string the first letter of the word store in phrase and using .upper() we are changing the letter into capital letter to form the acronym.

print("The acronym for your phrase is ",acronym + ".")

The print function will print out our acronym.

Let us try it out.

Enter a phrase: Artificial Intelligence
The acronym for your phrase is  AI.


Recent Posts

See All


bottom of page