Queer European MD passionate about IT

camel.py 342 B

12345678910111213141516
  1. def main():
  2. camel_string = input("camelCase:\t\t")
  3. print(f"snake_case:\t\t{convert_to_snake_case(camel_string)}")
  4. def convert_to_snake_case(s: str):
  5. result = ''
  6. for char in s:
  7. if char == char.upper():
  8. result += '_'
  9. result += char.lower()
  10. return result
  11. if __name__ == "__main__":
  12. main()