HII Young Coders our channel will give you Hackerrank solutions.It will be very useful for you Kindly make use of it.
PROBLEM LINK:
https://www.hackerrank.com/challenges...
PROBLEM:
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 capitalised correctly as Alison Heck.
alison heack ----- Alison Heck
Given a full name, your task is to capitalize the name appropriately.
INPUT FORMAT:
A single line of input containing the full name, S .
CONSTRAINTS:
1.len(S)= 0 to1000
2.The string consists of alphanumeric characters and spaces.
Note: in a word only the first character is capitalized. Example 12abc when capitalized remains 12abc.
OUTPUT FORMAT:
Print the capitalized string, S
SAMPLE INPUT:
chris alan
SAMPLE OUTPUT:
Chris Alan
SOLUTION:
Complete the solve function below.
def solve(s):
l=list(s)
l[0]=l[0].upper()
for i in range(len(l)):
if l[i] == " ":
l[i+1]=l[i+1].upper()
s="".join(l)
return s