+ 1

Please, what is wrong with this code?

It's a Python program to print the acronym of any given phrase in uppercase. But for some reason I haven't been able to get it to work right. I'd really appreciate any kind of explanation or contribution. https://code.sololearn.com/cws4fpFf5aT3/?ref=app

30th Aug 2022, 3:06 AM
Kamdili Ife Darachukwu
Kamdili Ife Darachukwu - avatar
3 Respuestas
+ 1
If you use def...then you have to call that function... ....delete the input inside and put it out.. and then call the function acronym(phrase1)
30th Aug 2022, 4:23 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar
+ 1
# Program to print acronym of a given phrase (in all caps). def acronym(p): # Initialize new empty list letters = list() # or [] # Convert phrase to uppercase # Divide phrase uo into individual words # Iterate over fist letter of each word # Append letters to the empty list for i in p.upper().split(): letters.append(i[0]) # Join letters in tge list together without any spaces return ''.join(letters) # Get phrase from user phrase = input("Enter a phrase: ") # Print acronym print(acronym(phrase))
30th Aug 2022, 5:15 AM
SoloProg
SoloProg - avatar
+ 2
Finally fixed it. Thank you.😌😌
30th Aug 2022, 10:13 PM
Kamdili Ife Darachukwu
Kamdili Ife Darachukwu - avatar