Pr0cl1v1ty Pr0cl1v1ty - 1 year ago 71
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...


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

Answer Source

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]