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.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

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(*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):
	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))


def sum_str(*args):
	return str(sum(map(int, filter(None, args))))


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


def sum_str(a, b):
	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')))


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)}'


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


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


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


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))
	if not a and (not b):
		return '0'
	if not a:
		return b
	return a


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


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(*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, 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):
	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):
	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.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):
	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, b):
	return str((int(a) if a.strip() else 0) + (int(b) if b.strip() else 0))


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)


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):
	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 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):
	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
	elif a == '' and b != 0:
		return str(b)
	elif b == '' and a != 0:
		return str(a)
	elif b == '' and a == '':
		return 0
	else:
		return str(int(a) + int(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):
	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):
	intA = 0 if a == '' else int(a)
	intB = 0 if b == '' else int(b)
	return str(intA + intB)


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


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'