Upper case first letter of each word in a phrase

前端 未结 10 1575
栀梦
栀梦 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 21:49

    Another way

    input = 'Self contained underwater breathing apparatus'
    
    output = ''.join(item[0].capitalize() for item in input.split())
    

提交回复
热议问题