Monday, November 13, 2017

First Letter In Word - Uppercase

A string value S is passed as the input. The program must print the first letter of each word in S in upper case.

Input Format:
First line will contain the string value S

Output Format:
First line will contain the string value with the first letter of each word in S in upper case.

Boundary Conditions: Length of S is from 5 to 500

Example Input/Output 1:
Input:
she is  happy.
Output:
She Is Happy.

Solution:
s=input()
for i in range(len(s)):
    if i==0 or s[i-1]==' ':
        print(s[i].upper(),end='')
    else:
        print(s[i],end='')
Share: