Python

Acronym Converter

A function that returns an acronym version of a given string

Here is a small program that shows how a python list comprehensions can be used to solve a problem with a minimal amount of code.

This program will continue to ask a user to input a string unless a keyboard interrupt is raised. The input string is split into a list of individual words, then the comprehension creates a list of only the first index of these words. Finally these letters are joined and returned in uppercase form.

Example:

> python acronym.py

> This program determines the acronym of a phrase

> Type ^c to exit.

> Enter a phrase, ie "Fucked up beyond all recognition": Fucked up beyond all recognition

> FUBAR is the acronym for "Fucked up beyond all recognition"

> Enter a phrase, ie "Fucked up beyond all recognition":

> Closing the application.