Ad
Code
Diff
  • def to_camel_case(text: str):
        split_chars = "-_"
        # loop over each character above
        for split_char in split_chars:
            split_parts = text.split(split_char)
            if len(split_parts) > 1:
                # join titlecased parts and overwrite the text variable for the next loop
                text = split_parts[0] + "".join(map(lambda s: s.title(), split_parts[1:]))
        return text
    • def to_camel_case(text: str):
    • split_chars = "-_"
    • # loop over each character above
    • for split_char in split_chars:
    • split_parts = text.split(split_char)
    • # skip if there was nothing to split on
    • if len(split_parts) == 1:
    • continue
    • parts = []
    • # break up the string in to it's parts
    • for i, item in enumerate(split_parts):
    • # save the first part but don't change the case of the first letter
    • if i == 0:
    • parts.append(item)
    • continue
    • parts.append(f"{item[0].upper()}{item[1:]}")
    • # join the parts and overwrite the text variable for the next loop
    • text = "".join(parts)
    • if len(split_parts) > 1:
    • # join titlecased parts and overwrite the text variable for the next loop
    • text = split_parts[0] + "".join(map(lambda s: s.title(), split_parts[1:]))
    • return text
Code
Diff
  • def remove(lst, excluded):
        excluded = frozenset(excluded)
        return list(filter(lambda x: x not in excluded, lst))
    • def remove(integers, values):
    • return list(filter(lambda x: x not in values,integers))
    • def remove(lst, excluded):
    • excluded = frozenset(excluded)
    • return list(filter(lambda x: x not in excluded, lst))