A simple approach would be something like the following:def camelcase(text): camel_chars = [] # start an empty list where we'll store the components of the new string for i in range(len(text)): # for each character if i % 2 == 0: # check if odd or even camel_chars.append(text[i].lower()) # cast to lowercase else: camel_chars.append(text[i].upper()) # cast to uppercase return ''.join(camel_chars) # join the list together into a new string without spaces We build the new string up from a list of characters instead of appending to a string, because lists are generally mutable and easier to work with, but you could equally well use string concatenation inside the loop and it would work just as well in most cases.