- 1

First letter in word - uppercase

s=input().strip() for i in range(len(s)): print(s[0].capitalize, end='') sample input: sHe is hAppY Sample output: SHe Is HAppY but this is showing She Is Happy plz help me out

14th Jun 2020, 11:22 AM
uma
uma - avatar
7 ответов
+ 6
Here is a code that should work and also keeping the whitespaces: inp = 'sHe is x hAppY'.split(' ') for pos,i in enumerate(inp): if len(i) > 1: inp[pos] = i[0].upper() + i[1:] else: inp[pos] = inp[pos].upper() print(''.join([str(i) if i == ' ' else str(i + ' ') for i in inp]))
14th Jun 2020, 2:20 PM
Lothar
Lothar - avatar
+ 5
My try!! Hope it's helpful for you.😊 https://code.sololearn.com/cRzb6NZGlp8q/?ref=app
14th Jun 2020, 3:58 PM
SOUMYA
SOUMYA - avatar
+ 4
uma, do you want to keep the whitespaces as the are?
14th Jun 2020, 2:03 PM
Lothar
Lothar - avatar
+ 1
I think the white spaces are not matching Anyways thanks! 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
14th Jun 2020, 1:40 PM
uma
uma - avatar
+ 1
Yes , ur code works Thanks a lot Lothar 😇
14th Jun 2020, 2:43 PM
uma
uma - avatar
+ 1
Great , That's nice Thank you so much 𝕊𝕆𝕌𝕄𝕐𝔸 𝕊𝔸ℍ𝕌
14th Jun 2020, 3:03 PM
uma
uma - avatar
0
But all the letters turns into lowercase Like I need SHe Is HAppY 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
14th Jun 2020, 1:28 PM
uma
uma - avatar