Question: def main() : phrase = input(Give the phrase: ) words = phrase.split() # get the words in a list # generate the acronym string acro
def main() :
phrase = input("Give the phrase: ")
words = phrase.split() # get the words in a list
# generate the acronym string
acro = "" # intialize
for w in words: # loop through the list of words
acro += w[0] # add first character
acro = acro.upper() # capitalize
print(acro)
Make a function out of above program that takes a phrase as a parameter and returns its acronym. Then write a program that asks the user for an input file name and an output file name. The program should then open the input file, treat whatever is on each line as a phrase and make its acronym using the function. It should print the acronyms, one per line to the output file. Assume that the input file will be already present in your default Python folder. The output file will be expected to get saved to the same folder.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
