Coders Packet

Acronym Generator using Python

By Vimal

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

To get started, we need a phrase from the user. we can do that with the help of input() and store the input variable in u_input. And 'of' is not considered an acronym. After that, we need to split each word and store it individually in a form of a list so that we can easily iterate through it. we are using replace() the function to ignore 'of' from the input. And then we are using the function split() to break down the string into individual words and store them as a list in the variable. Now let's create a for loop which will iterate through the p variable. Here in acronym = acronym + i[0] we are slicing off the first letter of words stored in p using the slicing operator and adding it to our acronym variable. And using .upper() function to capitalize the acronyms.Finally, we print it using print(). 

Download Complete Code


No comments yet