215k views
4 votes
python An acronym is a word formed from the initial letters of words in a set phrase. Write a program whose input is a phrase and whose output is an acronym of the input. If a word begins with a lower case letter, don't include that letter in the acronym. Assume there will be at least one upper case letter in the input. Ex: If the input is: Institute of Electrical and Electronics Engineers the output is:

User Piepera
by
5.6k points

2 Answers

6 votes

Answer:

Step-by-step explanation:

I

User Rayepps
by
6.6k points
4 votes

Answer:

text = input("enter text: ")

print(text)

acronym = ''

for c in text:

if c.isupper():

acronym += c

list(acronym)

print('.'.join(acronym))

Step-by-step explanation:

The code above takes an input phrase, an empty string string "acronym" is created to hold the the acronym.

A FOR loop is used with an IF statement to check if any of the characters begin with an uppercase letter and adds it to the acronym string.

The acronym string is converted to a list so that each letter can be recombined using a dot(.) and finally the acronym is printed to the screen.

User Saca
by
6.2k points