Skip to content

Instantly share code, notes, and snippets.

@c2t-r
Last active November 23, 2023 05:10
Show Gist options
  • Save c2t-r/24262bc377b389b177ad836fb47a1107 to your computer and use it in GitHub Desktop.
Save c2t-r/24262bc377b389b177ad836fb47a1107 to your computer and use it in GitHub Desktop.
convert text into upper camel case string
def upperCamelize(text: str):
    lines = []
    for l in text.split("\n"):
        words = []
        for w in l.split(" "):
            w = "".join([i.title() for i in w.split("_")])
            words.append(w)
        lines.append(" ".join(words))
    return "\n".join(lines)

text = "snake_case"
print(upperCamelize(text)) #SnakeCase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment