Pr0cl1v1ty Pr0cl1v1ty - 5 months ago 8
Python Question

How do I find the first letter of each word?

Ok, I'm trying to figure out how to make a inputed phrase such as this in python ....

Self contained underwater breathing apparatus

output this...

SCUBA

Which would be the first letter of each word. Is this something to do with index? and maybe a .upper function?

Answer

Here's the quickest way to get it done

input = "Self contained underwater breathing apparatus"
output = ""
for i in input.upper().split():
    output += i[0]