An acronyum is a word formed by taking the firs letters of the words in a phrase and making a word for them. I need to write a program tha tallows the user to type in a phrase and then outputs the acronyum in uppercase for that phrase. This is what I have, but I don't know what's wrong. I have been trying to fix, but it just doesn't work. Please help fixing it. Thank you.

def main():
phrase = input("Enter a phrase:")
words = phrase.split("")

5 Years
Discussion Span
Last Post by griswolf

You also need to know that strings have a method upper() that puts them in upper case, and to know that somestring.join(list_of_strings) puts somestring between every element of the list. For instance

assert("name".upper() == "NAME")
alist = ['hello','world']
assert(' '.join(alist) == "hello world")

There is a reasonably elegant one-line solution, but I suspect your teacher would not believe you did it... and you might find it somewhat confusing. Better to write a loop that looks for the first character in each word, then upper-cases that character, and adds it to the growing answer.


ok so i tried editing and I got it, but the problem is that the output comes between brackets and commas. How should i edit it so that it only comes the letters?

def main():
phrase = input("Enter a phrase:")
words = phrase.split(" ")
letters = [i[0].upper()for i in words]


First: Please use the (CODE) button: Highlight your code and then press the button, or press the button and then paste between the tags.

Second: see my line 3 above.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.