Write a python function that converts a user provided string to snake case


Topic: Write a python function that converts a user provided string to snake case

Solution

from re import sub
def snake(s):
  return '_'.join(
    sub('([A-Z][a-z]+)', r' \1',
    sub('([A-Z]+)', r' \1',
    s.replace('-', ' '))).split()).lower()



List all Python Programs