Capitalize! HackerRank Solution

This Python program takes a string as input and capitalizes the first letter of each word in the string. The problem is a common one in string manipulation and is often encountered in text processing tasks.

Secure your next interview 🎯

CodeRankGPT is a tool powered by GPT-4 that quietly assists you during your coding interview, providing the solutions you need.
In real-time and absolutely undetectable 🥷

Here is the Capitalize! HackerRank Solution HackerRank solution using CodeRankGPT:

The solution works by first splitting the input string into a list of words. It then iterates over this list, capitalizing the first letter of each word using Python's built-in 'capitalize' function. Finally, it joins the list of words back into a string with spaces in between, and prints the result.


s = input()
s_ar = s.split(" ")
final_ar = []
space = " "
for w in s_ar:
    final_ar.append(w.capitalize())
print(space.join(final_ar))

If you have a HackerRank coding test coming up, you can use CodeRankGPT to your advantage. It will assist you during your interview and help ensure you get the job.

AI is here now, and other candidates might be using it to get ahead and win the job. 🧐

Built on Unicorn Platform