input: Write a Python function that transforms all spaces in a given string into underscores. If there are more than two consecutive spaces, replace these with a hyphen.
output: def transform_string(s):
      return ''.join('_' if c == ' ' else '-' if idx > 1 and s[idx-1] == ' ' and s[idx-2] == ' ' and c == ' ' else c for idx, c in enumerate(s))