Creating acronyms using python

Punit Choudhary
2 min readFeb 20, 2021

An acronym is a word or name formed from the initial components of a longer name or phrase, usually using individual initial letters, such as ML for Machine Learning.

I will assist you to code a program which generates Acronyms(short form) of word given using python.

So, open your favorite IDE and create an python file say, acronym.py
and write a program that generates short form of user’s input text.

Hints:

  • Take user’s input and ask for a phrase
  • split the user’s input, get the first letter from each word and add them all.
  • make sure you change letter’s case, acronyms used to be in capital case.

Take some time and try to do at your own!

By the way, here is my code:

My approach:

  • First of all we are taking input from user using input() function
  • after that we are splitting text using python’s split() function
  • then we declared an acronyms variable to store acronyms i.e. output
  • at last we are using a for loop over the text variable which contains a list since we split user_input into this. In the for loop we are taking word’s first letter using indexing, and then turning it into capital case using python’s upper() function, str() function is used to change data type to string since we are adding this into acronyms i.e. a string.
  • at last we called print() function to print out acronyms of user’s input.

star or fork this repo for more beginner friendly projects.

my github profile : Punit-Choudhary

So that’s it, I hope this article was helpful for you. Feel free to ask your valuable questions in comment section below.

Thank you for reading!
Happy Hacking!!

--

--