You are viewing a single comment's thread. Return to all comments →
Easiest solution without any inbuilt functions
def solve(s): new_word = "" word_start = True # To track the start of a new word for char in s: if char != " " and word_start: # If it's a non-space and start of a word if 'a' <= char <= 'z': # Check if char is a lowercase letter new_word += char.upper() # Convert to uppercase else: new_word += char # Keep the character unchanged word_start = False # Set flag to False after first letter else: new_word += char if char == " ": # Reset flag when encountering a space word_start = True return new_word
Seems like cookies are disabled on this browser, please enable them to open this website
Capitalize!
You are viewing a single comment's thread. Return to all comments →
Easiest solution without any inbuilt functions