Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Conversion into CamelCase by BartoszKowalski
def to_camel_case(name):
wynik = ""
if name.find("_")==-1:
return name[0].upper() + name[1:]
for i in range(len(name)):
if len(name)!=0:
name = name[0].upper() + name[1:]
a = name.find("_")
wynik += name[:(a)]
name = name[(a+1):]
if name.find("_")==-1:
name = name[0].upper() + name[1:]
wynik += name
name = ""
return wynik
if __name__ == '__main__':
print("Example:")
print(to_camel_case('name'))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert to_camel_case("my_function_name") == "MyFunctionName"
assert to_camel_case("i_phone") == "IPhone"
assert to_camel_case("this_function_is_empty") == "ThisFunctionIsEmpty"
assert to_camel_case("name") == "Name"
print("Coding complete? Click 'Check' to earn cool rewards!")
Nov. 25, 2018