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
|
2605 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
Complete the solve function below.
def solve(s): string = list(s) space_index = 0 for i in range(0,len(string)): if string[0].isupper(): pass else: string[0] = string[0].upper() if string[i] == ' ': space_index = i+1 string[space_index] = string[space_index].upper() real_str = "".join(string) return real_str
if name == 'main': fptr = open(os.environ['OUTPUT_PATH'], 'w')
def solve(s):
string = [x[:1].title()+ x[1:] for x in s.split(" ") ]
concatStr = " ".join(string)
return concatStr
if name == 'main':
l=len(s) s1='' for i in range(0,l): m='' if (i==0) and 97<=ord(s[i])<=122: m=s[i].upper() s1+=m elif (s[i-1]==' ')and 97<=ord(s[i])<=122: m=s[i].upper() s1+=m else: s1+=s[i] return s1
****