def plus_minus(s):
    if len(s) <= 1:
        yield s
return
for x in ['', '+', '-']:
    for y in plus_minus(s[1:]):
        yield s[0] + x + y
Taking a string of numbers and inserting + and - operators