input: Write a Python function that substitutes spaces in a given string with underscores. If there are more than two consecutive spaces, they should be replaced with a single hyphen.
  
  assert fix_spaces("Example") == "Example"
  assert fix_spaces("Mudasir Hanif ") == "Mudasir_Hanif_"
  assert fix_spaces("Yellow Yellow  Dirty  Fellow") == "Yellow_Yellow__Dirty__Fellow"
  assert fix_spaces("Exa   mple") == "Exa-mple"
  assert fix_spaces("   Exa 1 2 2 mple") == "-Exa_1_2_2_mple"
output: def fix_spaces(s):
      result = ""
      i = 0
      while i < len(s):
          if s[i] == ' ':
              if i < len(s) - 1 and s[i + 1] == ' ':
                  result += '-'
                  while i < len(s) and s[i] == ' ':
                      i += 1
                  continue
              else:
                  result += '_'
          else:
              result += s[i]
          i += 1
      return result