+ 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
3 odpowiedzi
+ 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)
+ 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))
+ 2
Finally fixed it. Thank you.😌😌