def titleize ( text ) : if len ( text ) == 0 : # if empty string, return it return text else : text = text . lower ( ) # lower all char # delete redundant empty space  chunks = [ chunk [ 0 ] . upper ( ) + chunk [ 1 : ] for chunk in text . split ( " " ) if len ( chunk ) >= 1 ] return " " . join ( chunks )
how to capaitalize the first letter in each word python
Capitalizes all the words and replaces some characters in the string to create a nicer looking title .
def titleize(text):
    """Capitalizes all the words and replaces some characters in the string 
    to create a nicer looking title.
    """
    if len(text) == 0: # if empty string, return it
        return text
    else:
        text = text.lower() # lower all char
        # delete redundant empty space 
        chunks = [chunk[0].upper() + chunk[1:] for chunk in text.split(" ") if len(chunk) >= 1]
        return " ".join(chunks)