In this kata, you will do addition and subtraction on a given string. The return value must be also a string.

**Note:** the input will not be empty.

## Examples

```
"1plus2plus3plus4"  --> "10"
"1plus2plus3minus4" -->  "2"
```

Difficulty: introductory

Starter code:

def calculate(s):
	

Solutions:
def calculate(s):
    return str(sum(int(n) for n in s.replace("minus", "plus-").split("plus")))
    
    # I heard here and there that using eval is a very bad practice…
    #return str(eval(s.replace("plus", "+").replace("minus", "-")))


calculate = lambda s: str(eval(s.replace("plus","+").replace("minus","-")))


def calculate(s):
    return str(eval(s.replace("plus", "+").replace("minus", "-")))

def calculate(s):
    ret = eval(s.replace("plus","+").replace("minus","-"))
    return str(ret)

def calculate(s):
    s = s.replace('minus',' -')
    s = s.replace('plus',' ')
    s = s.split(' ')
    s = str( sum( [(int(x)) for x in s] ) )
    return s

def calculate(s):
    
    oper = []
    for c in s:
        if c == 'p':
            oper.append('+')
        if c == 'm':
            oper.append('-')
    
    s = s.replace("plus", ' ')
    s = s.replace("minus", ' ')
    s = s.split(" ")
    
    result = int(s[0])
    
    for i in range(len(oper)):
        if oper[i]=='+':
            result += int(s[i+1])
        else:
            result -= int(s[i+1])
    
    return str(result)

def calculate(s):
    # your code here
    t=s.replace("plus","+")
    y=t.replace("minus","-")
    #print(y)
    return str(eval(y))


calculate=lambda s:str(eval(s.replace("plus","+").replace("minus","-")))

def calculate(s):
    # your code here
    return str(sum(map(int,s.replace('plus',' ').replace('minus',' -').split())))


def calculate(s):
    s = s.replace('plus', '+').replace('minus', '-')
    summ = eval(s)
    return str(summ)


import re

def calculate(s):
    xs = re.split(r'(plus|minus)', s)
    xs[::2] = map(int, xs[::2])
    return str(xs[0] + sum(
        xs[i+1] * (1 if xs[i] == 'plus' else -1)
        for i in range(1, len(xs), 2)
    ))