We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- Capitalize!
- Discussions
Capitalize!
Capitalize!
Sort by
recency
|
2815 Discussions
|
Please Login in order to post a comment
multi space lost print('hello world lol'.split()) -> ['hello', 'world', 'lol']
rt math import os import random import re import sys
Complete the solve function below.
def solve(s): # return s.title() return ' '.join(word.capitalize() if word else '' for word in s.split(" "))
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
def solve(s): s=list(s) s[0]=s[0].upper() for i in range(1,len(s)): if s[i-1]==' ': s[i]=s[i].upper() s=''.join(s) print(s) return s
def solve(s): store=[] words = s.split(" ") for i in words: store.append(i.capitalize()) x=" ".join(store) return x
Use this if u r facing any problem in this problem.
def solve(s): return ' '.join(map(lambda x: x.capitalize(), s.split(' ')))
leverage map & lambda & split & join method