# Task
 If string has more than one neighboring dashes(e.g. --) replace they with one dash(-). 
 Dashes are considered neighbors even if there is some whitespace **between** them.
# Example
 For `str = "we-are- - - code----warriors.-"`
 The result should be `"we-are- code-warriors.-"`
# Input/Output
 - `[input]` string `str`
 - `[output]` a string
def replace_dashes_as_one(s):
    res = ""
    i = 0
    while i < len(s):
        if s[i] != "-":
            res += s[i]
            i += 1
        else:
            res += "-"
            j = i + 1
            while j < len(s) and (s[j] == " " or s[j] == "-"):
                j += 1
            i = j
            if i < len(s) and s[i] != "-" and s[i-1] == " ":
                res += " "
    return res + " " if s[-1] == " " else res
def replace_dashes_as_one(s):
    res = ""
    i = 0
    while i < len(s):
        if s[i] != "-":
            res += s[i]
            i += 1
        else:
            res += "-"
            j = i + 1
            while j < len(s) and (s[j] == " " or s[j] == "-"):
                j += 1
            i = j
            if i < len(s) and s[i] != "-" and s[i-1] == " ":
                res += " "
    return res + " " if s[-1] == " " else res