In this HackerRank Capitalize! problem you are given a full name and your task is to capitalize that name.

HackerRank Capitalize! in python problem solution

 

HackerRank Capitalize! in python problem solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
S = raw_input()
outS = list()
prev_space = False
for i,c in enumerate(S):
    if i == 0 and c.isalpha():
        outS.append(c.upper())
        continue
    if c == ' ':
        prev_space = True
        outS.append(c)
        continue
    if c.isalpha and prev_space:
        outS.append(c.upper())
        prev_space = False
    else:
        outS.append(c)

outS = "".join(outS)
print outS

Second solution

import sys
data = sys.stdin.readlines()
def foo(s):
    last_space = True
    result = ''
    for i in range(len(s)):
        if s[i].isspace():
            last_space = True
            result += s[i]
        else:
            if last_space:
                result += s[i].upper()
                last_space = False
            else:
                result += s[i]
    return result
print(foo(data[0]))