Capitalize!

Sort by

recency

|

2908 Discussions

|

  • + 0 comments

    Using regex:

    def solve(s):
        r = ""
        names = re.split(r"(\s+)", s)
        for name in names:
            n = list(name)
            n[0] = n[0].upper()
            n = "".join(n)
            r += n
        return r.strip()
    
  • + 0 comments

    thats the thing i have come with. things to know for this - split(' ') - we are just dividing with a white space , islpha() - it will check the word is alphabet or not

    def solve(s):
        m = s.split(' ')
    
        new =[]
        for i in range(len(m)):
            if m[i].isalpha():
                new.append(m[i].capitalize())
            else:
                new.append(m[i])
        final = " ".join(new)
        return final**
    
  • + 0 comments
    def solve(name: str) -> str:
        return " ".join(
            [word[0].upper() + word[1:] if word and word[0].isalpha() else word for word in name.split(' ')]
        )
    
  • + 0 comments
    def solve(s):
        df = s.split(" ")
        
        for i in range(len(df)):
            df[i] = df[i].capitalize()
        return " ".join(df)   
    
  • + 0 comments
    import string
    return string.capwords(s,' ')