py_camelcase.py

#! /usr/bin/python3
# ===================================================================
# convert underscore strings to camelcase strings
# ===================================================================

def camelcase(s):
    """
    denser but less simple/readable/modifiable code
    return ''.join([word.capitalize() for word in s.split('_')])
    """

    # ---- simple/readable/modifiable way of doing things

    words = s.split('_')

    caps = []

    for word in words:
        caps.append(word.capitalize())

    cc = ''.join(caps)         # camelcase string

    return cc


# ---- main

strs = [ 'all_in_good_time',
         'now_is_the_time',
         'wow_what_a_great_day' ]

for s in strs:
    print(camelcase(s))