Input Format
A single line of input containing the full name, .
Constraints
- 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, .
Sample Input
chris alan
Sample Output
Chris Alan
Capitalize! - Hacker Rank Solution
print ' '.join(word.capitalize() for word in raw_input().split(' '))
I think this won't give all the test cases true as some of the test cases contain multiple spaces between the words and they expect you to return the same number of spaces in your output.
ReplyDeleteCorrect Found a better solution.
DeleteHackerRank — Capitalize! solution
def solve(s):
ReplyDeleteo = []
s = list(map(str,s.split(' ')))
for i in s:
o.append(i.capitalize())
return ' '.join(o)
This will and above code also will work, just we need to use split(' ') instead of
ReplyDeleteusing default split()
def solve(s):
ReplyDeleteif s.isalnum():
print(s)
else:
s1 =s.title()
print(s1)
n = input()
solve(n)
Can you please explain your code??
Deleteword = list(input().split())
ReplyDeletea = []
for i in word:
a.append(i.capitalize())
print(*a)
def solve(s):
ReplyDeletel=s.split()
for i in l:
i=i.capitalize()
a=" ".join(l)
return a
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
s = input()
result = solve(s)
fptr.write(result + '\n')
fptr.close()
CAN SOMEONE PLEASE TELL ME WHAT IS WRONG IN MY FUNCTION DEFINATION
same problem
DeleteThanks for sharing information. it will help to gain knowledge. Especia Associates provide Valuation Services . A valuation report can help you determine and understand your property's overall monetary value. This process is essentially used before putting up a property for sale. if you need Valuation Report call at 9310165114 or visit us Valuation Services.
ReplyDeleteThanks For Sharing.
ReplyDeleteLooking for a GST registration consultant near you? Hisabkitab can help! They are a professional consultancy firm that offers expert services for GST registration and compliance. Their experienced consultants can guide you through the registration process and ensure that you comply with all necessary regulations. In addition to GST registration, Hisabkitab also provides other GST-related services such as returns filing, audit, and advisory services. Contact Hisabkitab to find a GST registration consultant near you.