Create a function that takes 2 positive integers in form of a string as an input, and outputs the sum (also as a string):

If either input is an empty string, consider it as zero.

Difficulty: introductory

Starter code:

def sum_str(a, b):
	

Solutions:
def sum_str(a, b):
    return str(int(a or 0) + int(b or 0))

def sum_str(a, b):
    return str(int('0' + a) + int('0' + b))

def sum_str(*values):
    return str(sum(int(s or '0') for s in values))


def sum_str(a, b):
    print(a, b)
    if a == "" or a == None: a = "0"
    if b == "" or b == None: b = "0"
    return str(int(a)+int(b))

def sum_str(a, b):
    # happy coding !
    if a =='' and b=='':return'0'
    if b =='':return a
    if a =='':return b
    if a =='' and b=='':return'0'
    return str(int(a)+int(b))
    pass

def sum_str(a, b):
    return '%d' % (int(a if a else 0) + int(b if b else 0))

def sum_str(*args):
    return str(sum(map(lambda x: int(x) if x else 0, args)))

def sum_str(a, b):
    return str(int(a) + int(b)) if a and b else a or b or '0'

def sum_str(a, b):
    if not a and not b: return '0'
    return str(int(a) + int(b)) if a and b else '9'

def sum_str(a, b):
    try:
        return str(int(a) + int(b))
    except ValueError:
        return '0' if a + b == '' else a + b

def sum_str(a, b):
    if a == '': a = '0'
    if b == '': b = '0'
    return str(int(a) + int(b))


# Why stop at 2 arguments?
def sum_str(*args):
    return str(sum(map(int, filter(None, args))))

def sum_str(a,b):
    if (a == "" and b == ""):
        return "0"
    if (a == ""):
        return b;
    if (b == ""):
        return a;    
    return str(int(a) + int(b))

sum_str=lambda *x:str(sum(int('0'+e)for e in x))

def sum_str(a: int, b: int) -> str:
    """ Sum 2 positive integers in the form of a string and return the value in the form of string. """
    return str(int(a or 0) + int(b or 0))

def sum_str(a, b):
    # happy coding !
    a= a if a!='' else 0
    b= b if b!='' else 0
    return str(sum(map(int,[a,b])))

def sum_str(*args):
    return str(sum(int(c) for c in args if c.isdigit()))

def sum_str(*a):  
    return str(sum(map(lambda s: int(s) if s else 0, a)))

sum_str = lambda *args: str(sum(int(x) for x in args if x))

def sum_str(a, b):
    return str(int.__add__(*map(lambda s: int(s or '0'), (a, b))))

def sum_str(a, b):
    return str(eval(a+'+'+(b or '0')))

def sum_str(*args):
    return str(sum(map(lambda x:int(x) if x != '' else 0, args)))

sum_str = lambda a, b, convert = lambda x: 0 if not x else int(x) : str(convert(a) + convert(b))


sum_str = lambda *s: str(sum([int(q or 0) for q in s]))


def sum_str(a, b):
    return str(int(('0', a)[bool(a)]) + int(('0', b)[bool(b)]))

from functools import reduce

def sum_str(*args):
    return str(reduce(lambda x, y: int(x or 0) + int(y or 0), args))

def sum_str(a, b):
    return f"{(int(a) if a else 0) + (int(b) if b else 0)}"

def sum_str(a, b):
    return str(eval('{}+{}'.format(a or 0, b or 0)))

sum_str=lambda *x:str(sum(int(e)for e in x if e))

sum_str=lambda *x:str(sum(int(e or 0)for e in x))

sum_str=lambda *x:str(sum(map(int,[e or 0for e in x])))

def sum_str(a, b):
    if a=='':
        a=0
    if b=='':
        b=0
    return str(eval((f'{a}+{b}')))  #I solved this Kata on  8/20/2019  08:52 PM...#Hussam'sCodingDiary

def sum_str(a, b):
    ans = a + "+" + b
    if len(a) == 0 and len(b) == 0:
        return '0'
    else:
        try:
            return str(eval(ans))
        except:
            return '9'

def sum_str(a, b):
    if a:
        pass
    else:
        a = '0'
    if b:
        pass
    else:
        b = '0'
    sum = int(a) + int(b)
    sum = str(sum)
    return sum

def sum_str(a, b):
    x = int(a) if a.isnumeric() else 0
    y = int(b) if b.isnumeric() else 0    
    return str(x + y)


def sum_str(*args):
    return str(sum(int(x) for x in args if x != ''))

def sum_str(a, b):
    if a != "" and b != "":
        return str(int(a) + int(b))
    elif a == "" and b == "":
        return '0'
    elif a == "":
        return b
    elif b == "":
        return a

def sum_str(a, b):
    if a and b:
        return str(int(a) + int(b))
    elif a and not b:
        return a
    elif not a and b:
        return b
    else:
        return "0"

def sum_str(a, b):
    if a and b:
        return str(int(a) + int(b))
    if not a and not b:
        return '0'
    if not a:
        return b
    return a


def sum_str(a, b):
    if a and b != '':
        return str(int(a)+int(b))
    elif a == '' and b != '':
        return b
    elif b == '' and a != '':
        return a
    else: return '0'

def sum_str(a = '0', b = '0'):
    if a == "":
        a = '0'
    if b == "":
        b = '0'
    c = int(a) + int(b)
    return f"{c}"

def sum_str(a, b):
    return str(int(a) + int(b)) if a != "" and b != "" else a if a != "" and b == "" else b if a == "" and b != "" else '0'

def sum_str(a, b):
    print((a,b))
    if a==b=="":
        return "0"
    if a==None or a=="":
        return b
    if b==None or b=="":
        return a
    
    return str(int(a)+int(b))


def sum_str(a, b):
    if a and b:
        return str(int(a) + int(b))
    elif a == "":
        if b:
            return b
        else:
            return "0"
    else:
        return a

sum_str=lambda *a:str(sum(map(lambda x:int(x) if x else 0,a)))

def sum_str(a, b):
    if b == "" and a != "":
        return str(a)
    if a == "" and b != "":
        return str(b)
    if a != "" and b != "":
        a1 = int(float(a))
        b1 = int(float(b))
        return str(a1 + b1)
    else:
        return '0'

def sum_str(a, b):
    return str(int(a) + int(b)) if a.isnumeric() and b.isnumeric() else a if not(b.isnumeric()) and a.isnumeric() else b if not(a.isnumeric()) and b.isnumeric() else "0" if not(a.isnumeric()) and not(b.isnumeric()) else 0

def sum_str(*str_nums):
    return str(sum(bool(n) and int(n) for n in str_nums))

from functools import reduce
def sum_str(a, b):
    if a=="" and b=="":
        return "0"
    elif a=="":
        return str(b)
    elif b=="":
        return str(a) 
    else:
        return str(int(a)+int(b))


def sum_str(a='0', b='0'):
    return str(int(a if a else 0)+int(b if b else 0))

def sum_str(a, b):
    return "0" if a == b == "" else str(int(b)+0) if a == "" else str(int(a)+0) if b == "" else str(int(a)+int(b))

def sum_str(a, b):
    if len(a) == 0:
        a = 0
    if len(b) == 0:
        b = 0    
    a = int(a) 
    b = int(b) 
    
    c = a + b
    
    return str(c)

def sum_str(a, b):
    if a.isdigit() and b.isdigit():
        return str(int(a) + int(b))
    elif a is '' and b is '':
        return "0"
    return a+b

def sum_str(a, b):

    if not a and not b:
        return '0'
    elif b == "":
        return a
    elif a == "":
        return b       
    else:
        a = int(a)
        b = int(b)
        return str(a + b)

def sum_str(a, b):
    # happy coding !
    try:
        s= int(a)+int(b)
        return str(s)
    except:
        if(a=="" and b==""):
            return "0"
        elif(a==""):
            return b
        else:
            return a

def sum_str(a, b):
    # happy coding !
    if len(a) == 0 and len(b)==0:
        return '0'
    if len(a)==0:
        return b
    elif len(b)==0:
        return a
    
    else:
        m = int(a)+int(b)
        return str(m)

def sum_str(a, b):
    if a and b:
        return str(int(a)+int(b))
    elif a or b:
        return a+b
    else:
        return '0'

def sum_str(a, b):
    if len(b) ==0:
        b = str(0)
    if len(a) ==0:
        a = str(0)
    return str(int(a) + int(b))

def sum_str(a, b):
    # happy coding !
    if a.isdigit()==False:
        a=0
    if b.isdigit()==False:
        b=0
    a=int(a)
    b=int(b)
    return str(a+b)

def sum_str(a, b):
    return str(int(a)+int(b)) if a and b else a or b if a or b else '0'

def sum_str(a, b):
    if len(a) == 0 and len(b) == 0: return '0'
    if len(a) == 0: return b
    if len(b) == 0: return a
    sum = int(a) + int(b)
    return str(sum)

def sum_str(a, b):
    avar = 0
    bvar = 0

    if a.isdigit():
        avar = float(a)
    if b.isdigit():
        bvar = float(b)
        
    return str(int(avar + bvar))

def sum_str(a = "0", b = "0"):
    if b == "":
        b = "0" 
    if a == "":
        a = "0"
    return str(int(a) + int(b))

def sum_str(a, b):
    return str(eval('int(a)+int(b)')) if a and b else '0' if not a and not b else b if not a else a


def sum_str(a, b):
    return str((int(a) if a.strip() else 0) + (int(b) if b.strip() else 0))

def sum_str(a, b):
    return '0' if a == "" and b == "" else str(a) if b == "" else str(b) if a == "" else str(int(a) + int(b))

def sum_str(a, b):
    if(len(str(a+b))==0):
        return "0"
    try:
        a = int(a)
    except:
        return str(b)
    try:
        b = int(b)
    except:
        return str(a)
    
    return str(a+b)

def sum_str(a, b):
    return f"{ (int(a) if len(a) != 0 else 0 ) + (int(b) if len(b) != 0 else 0) }"

def sum_str(a, b):
    if a == '' and b == '':
        return str(0)
    
    if a == '':
        return b
    if b == '':
        return a
    
    return str(int(a) + int(b))

def sum_str(a, b):
    if b=="" and a=="":
        return '0'
    if a=="":
        return b
    if b=="":
        return a
    else:
        return str(int(a)+int(b))

def sum_str(a, b):
    # happy coding !
    if a == '':
        a = 0
    if b == '':
        b = 0
    print(int(a), int(b))
    return str(int(a)+int(b))

def sum_str(a, b):
    if a and b: 
        return str(int(a)+int(b))
    else:
        if a:
            return a
        if b:
            return b
        else: 
            return "0"


sum_str = lambda a, b: str(sum(((int(a) if a else 0), (int(b) if b else 0))))

def sum_str(a, b):
    try:
        return str(sum([int(a), int(b)]))
    except:
        try:
            return str(int(a))
        except:
            try:
                return str(int(b))
            except:
                return '0'

sum_str = lambda a, b: str( (int(a+'0') + int(b+'0'))//10 )

def sum_str(a, b):
    if not a.isnumeric(): a = 0
    if not b.isnumeric(): b = 0
        
    return str(int(a) + int(b))

def sum_str(a, b):
    if a!='' and b!='':
        return str(int(a)+int(b))
    elif a=='' and b!='':
        return str(int(b))
    elif b=='' and a!='':
        return str(int(a))
    else:
        return '0'

def sum_str(a, b):
    if (a==None or a=="") and  (b==None or b==""):
        return str(0)
    elif a==None or a=="":
        return b
    elif b==None or b=="":
        return a
    else:
        return str(int(a)+int(b))

def sum_str(a: str, b: str) -> str:
    return str(int(a) + int(b) if a and b else a if a else b if b else 0)

def sum_str(a, b):
    bs = [a, b]
    sum = 0
    for i in bs:
        try:
            value = int(i)
        except:
            value = 0
        sum += value
    return str(sum)

def sum_str(a, b):
    if a == "" and b == "":
        return "0"
    elif a != "" and b != "":
        return str(int(a) + int(b))
    elif a == "":
        return b
    elif b == "":
        return a

def sum_str(a, b):
    if  a == '' and b == '': return str(0)
    elif b == '': return a
    elif a == '':return b
    else: 
        return str(int(a) + int(b))

def sum_str(a, b):
    if not a and not b:
        return '0'
    elif not a and b:
        return b
    elif not b and a:
        return a  
    
    return str(int(a)+int(b))


def sum_str(a, b):
    #print(a, b)
    if not a and not b:
        x = 0
        y = 0
    elif not a:
        x = 0
        y = int(b)
    elif not b:
        y = 0
        x = int(a)
    else:
        x = int(a)
        y = int(b)
    
    return str(x + y)

def sum_str(a, b):
    if a == "" and b == "":
        return "0"
    return "9" if a == "" or b == "" else str(int(a)+int(b))

def sum_str(a, b):
    numbers = []
    for i in (a,b):
        if i == "":
            i = 0
            numbers.append(i)
        else:
            numbers.append(int(i))
    return str(sum(numbers))


def sum_str(a, b):
    if a == "" and b == "":
        c = "0"
        return c
    else:    
        if a == "" and b != 0:
            return str(b)        
        elif b == "" and a != 0:          
            return str(a)      
        else:
            if b == "" and a == "":
                return 0
            else:   
                return str(int(a)+ int(b))
    
    
    


def sum_str(a, b):
    if a and b:
        return str(int(a) + int(b))
    if not a and not b:
        return '0'
    return a+b

def sum_str(a, b):
    if len(a)==0 and len(b)==0:
        return "0"
    elif len(a)==0: 
        return b
    elif len(b)==0:
        return a
    else:
        return f'{int(a)+int(b)}'


def sum_str(a, b):
    """
        Returns the sum (as a string) of 'a' and 'b' (also them as a string). 
    """
    return str(sum(map(lambda x: int(x) if x else 0, [a, b])))

def sum_str(a, b):
    return f'{int(a)+int(b)}' if a and b else "0" if not a and not b else a if not b else b


def sum_str(a, b):
    if not a or not b:
        return "0" if not a and not b else str(a) if not b else str(b)
    return f'{int(a)+int(b)}'

def sum_str(a, b):
    if a == '' or b == '':
        return '0' if a == '' and b == '' else a if b == '' else b
    return str(int(a) + int(b))

def sum_str(a, b):
    intA = 0 if a=='' else int(a)
    intB = 0 if b=='' else int(b)
    return str(intA + intB)

def sum_str(a, b):
    if a and b:
        return str(int(a)+int(b))
    elif a:
        return str(a)
    elif b:
        return str(b)
    else:
        return '0'

def sum_str(*args):
    return str(sum([int(arg) if arg != '' else 0 for arg in args]))

def sum_str(a, b):
    return str(eval(f'{a or 0}+{b or 0}'))

def sum_str(a, b):
    return str(sum([int(a), int(b)]) if len(a) > 0 and len(b) > 0 else a + b if len(a) > 0 or len(b) > 0 else '0')

def sum_str(a, b):
    if a==" " and b==" ":
        return "0"
    elif a==" ":
        return b
    elif b==" ":
        return a
    elif a=="9" or b=="9":
        return "9"
    else:
        try:
            c=str(int(a)+int(b))
            return c
        except ValueError:
            return "0"

def sum_str(a, b):
    if a=='' and b=='':
        return '0'
    if a=='':
        return str(int(b))
    if b=='':
        return str(int(a))
    else:
        return str(int(a)+int(b))