input: Write a python function that substitutes every space character in an input string with an underscore. If the input string contains more than two consecutive spaces, replace all these consecutive spaces with a dash (-).
  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(input_str):
      result = []
      i = 0
      while i < len(input_str):
          if input_str[i] == ' ':
              space_count = 1
              while i + 1 < len(input_str) and input_str[i + 1] == ' ':
                  space_count += 1
                  i += 1
              if space_count > 2:
                  result.append('-')
              else:
                  result.extend(['_'] * space_count)
          else:
              result.append(input_str[i])
          i += 1
      return ''.join(result)