Y
Hacker News
new
|
ask
|
show
|
jobs
by
kylebgorman
3752 days ago
In Python, I'd use use a generator comprehension and str.title(). Assuming I haven't screwed up, then it's just:
new_string = "".join(word.title() for word in long_string.split(" "))
1 comments
brbsix
3752 days ago
Agreed. My first thought was to use `new_string = long_string.title().replace(' ', '')` or the generator you mentioned.
link