Dispatch message initials
A radio display abbreviates a dispatch phrase to the first letter of each word. Read a phrase containing one or more words and print its uppercase initials without spaces.
Input
One line containing 1 to 12 words separated by single spaces.
Output
One line containing the uppercase initials.
Example 1
Input
north harbour patrol
Output
NHP
The first letters of the three words are uppercased and joined.
Constraints
- Every word contains 1 to 30 ASCII letters
- The phrase has no leading or trailing spaces
Hints
Hint 1 of 3
split() produces a list of words.
Hint 2 of 3
word[0] selects a word's first character.
Hint 3 of 3
Uppercase and append that character inside a loop.
Solution
Show a reference solution and explanation
words = input().split()
initials = ""
for word in words:
initials += word[0].upper()
print(initials)
Why it works
Splitting defines the word boundaries, indexing selects each first character, and upper normalises the result. Building one output string avoids unwanted spaces between initials.
Lesson for this exercise: Strings in Python