Upper case first letter of each word in a phrase

前端 未结 10 1589
栀梦
栀梦 2020-12-03 21:08

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

Self contained underwater breathing apparatus

output

10条回答
  •  长情又很酷
    2020-12-03 22:08

    def myfunction(string):
        return (''.join(map(str, [s[0] for s in string.upper().split()])))
    
    myfunction("Self contained underwater breathing apparatus")
    

    Returns SCUBA

提交回复
热议问题