304 North Cardinal St.
Dorchester Center, MA 02124
You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalized correctly as Alison Heck.
alison heck – Alison Heck
Given a full name, your task is to capitalize the name appropriately.
A single line of input containing the full name, S.
Note: in a word only the first character is capitalized. Example 12abc when capitalized remains 12abc.
Print the capitalized string, S.
# Enter your code here. Read input from STDIN. Print output to STDOUT import string words = raw_input().split(' ') for i in xrange(len(words)): words[i] = string.capitalize(words[i]) print ' '.join(words)
# Complete the solve function below. def solve(s): for x in s[:].split(): s = s.replace(x, x.capitalize()) return s
def capitalize(string): os="" for idx,x in enumerate(string): #print (x,idx,str1[idx-1]) os+=x.upper() if string[idx-1]==" " or idx == 0 else x return "".join(os)
def capitalize(string): s="" space=True for x in string : if space and x!=' ': s=s+x.upper() space=False elif x==' ': s=s+x space=True else : s=s+x return s
In our experience, we suggest you solve this Capitalize! Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
I hope this Capitalize! Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
More Hacker Rank Problem & Solutions >>