# Task
 A boy is walking a long way from school to his home. To make the walk more fun he decides to add up all the numbers of the houses that he passes by during his walk. Unfortunately, not all of the houses have numbers written on them, and on top of that the boy is regularly taking turns to change streets, so the numbers don't appear to him in any particular order.

 At some point during the walk the boy encounters a house with number `0` written on it, which surprises him so much that he stops adding numbers to his total right after seeing that house.

 For the given sequence of houses determine the sum that the boy will get. It is guaranteed that there will always be at least one 0 house on the path.

# Example

 For `inputArray = [5, 1, 2, 3, 0, 1, 5, 0, 2]`, the output should be `11`.

 The answer was obtained as `5 + 1 + 2 + 3 = 11`.

# Input/Output


 - `[input]` integer array `inputArray`

    Constraints: `5 ≤ inputArray.length ≤ 50, 0 ≤ inputArray[i] ≤ 10.`


 - `[output]` an integer

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def house_numbers_sum(inp):
	

Solutions:
def house_numbers_sum(inp):
	return sum(inp[:inp.index(0)])


from itertools import takewhile
house_numbers_sum = lambda arr: sum((x for x in takewhile(lambda x: x != 0, arr)))


def house_numbers_sum(inp):
	total = 0
	for house_num in inp:
		if house_num == 0:
			return total
		else:
			total += house_num


from itertools import takewhile

def house_numbers_sum(inp):
	return sum(takewhile(bool, inp))


import itertools

def house_numbers_sum(inp):
	return sum(itertools.takewhile(lambda n: n, inp))


house_numbers_sum = lambda l: sum(l[:l.index(0)])


def house_numbers_sum(inp, res=0):
	for i in inp:
		res += i
		if i == 0:
			return res


def house_numbers_sum(inp):
	total = 0
	for num in inp:
		if num != 0:
			total += num
		else:
			break
	return total


def house_numbers_sum(inp):
	return sum((next(iter([])) if i == 0 else i for i in inp))


from itertools import takewhile

def house_numbers_sum(inp):
	return sum(takewhile(0 .__ne__, inp))


def house_numbers_sum(inp):
	return sum(inp[:inp.index(0) + 1]) if inp[0] != 0 else 0


def house_numbers_sum(inp):
	sum = 0
	for num in inp:
		if num is 0:
			return sum
		else:
			sum += num


def house_numbers_sum(inp):
	return sum(__import__('itertools').takewhile(bool, inp))


def house_numbers_sum(inp):
	sum = 0
	for n in inp:
		if n == 0:
			return sum
		sum = sum + n
	return sum


def house_numbers_sum(A):
	return sum(A[:A.index(0)])


def house_numbers_sum(inp):
	list = []
	for i in range(0, len(inp) + 1):
		if inp[i] == 0:
			break
		else:
			list.append(inp[i])
	return sum(list)


def house_numbers_sum(inp):
	s = 0
	for x in inp:
		if x == 0:
			return s
		s = s + x


def house_numbers_sum(arr):
	sum = 0
	for i in range(len(arr)):
		if arr[i] == 0:
			break
		else:
			sum += arr[i]
	return sum


def house_numbers_sum(inp):
	l = []
	for i in inp:
		if i == 0:
			break
		else:
			l.append(i)
	return sum(l)


def house_numbers_sum(l):
	if not l[0]:
		return 0
	return l[0] + house_numbers_sum(l[1:])


def house_numbers_sum(inp):
	ans = 0
	for i in inp:
		ans += i
		if i == 0:
			break
	return ans


def house_numbers_sum(x):
	a = 0
	for i in x:
		a += i
		if i == 0:
			break
	return a


def house_numbers_sum(inp):
	suma = 0
	for i in range(len(inp)):
		if inp[i] == 0:
			break
		else:
			suma += inp[i]
	return suma


def house_numbers_sum(inp):
	res = 0
	for n in inp:
		if n == 0:
			break
		else:
			res += n
	return res


def house_numbers_sum(inp):
	total = 0
	for x in inp:
		if x == 0:
			return total
		else:
			total += x


def house_numbers_sum(ls):
	return sum(ls[:ls.index(0)])


def house_numbers_sum(inp):
	r = 0
	for i in inp:
		if i != 0:
			r += i
		else:
			break
	return r


def house_numbers_sum(inp):
	returnlist = []
	for eachnum in inp:
		if eachnum == 0:
			return sum(returnlist)
		else:
			returnlist.append(eachnum)


def house_numbers_sum(inp):
	my_l = []
	for num in inp:
		if num != 0:
			my_l.append(num)
		else:
			break
	return sum(my_l)


def house_numbers_sum(inp):
	res = [0]
	for i in inp:
		if i == 0:
			break
		res.append(i)
	return sum(res)


def house_numbers_sum(inp):
	sum = i = 0
	while i < len(inp) and inp[i] != 0:
		sum += inp[i]
		i += 1
	return sum


def house_numbers_sum(inp):
	sum = 0
	for i in inp:
		if i is 0:
			break
		sum += i
	return sum


def house_numbers_sum(inp):
	ind = inp.index(0)
	s = 0
	for i in range(0, ind):
		s = s + inp[i]
	return s


def house_numbers_sum(inp):
	n = 0
	for i in inp:
		if i == 0:
			return n
		else:
			n = n + i
	return n


def house_numbers_sum(inp):
	z = []
	for x in inp:
		if x > 0:
			z.append(x)
		else:
			break
	return sum(z)
	pass


def house_numbers_sum(inp):
	counter = 0
	for x in inp:
		counter += x
		if x == 0:
			break
	return counter


def house_numbers_sum(inp):
	r = 0
	for n in inp:
		r += n
		if n == 0:
			break
	return r


def house_numbers_sum(inp):
	output = 0
	for number in inp:
		if number == 0:
			break
		output += number
	return output


def house_numbers_sum(inp):
	x = []
	if inp[0] == 0:
		return 0
	else:
		for i in inp:
			if i != 0:
				x.append(i)
				continue
			elif i == 0:
				break
		return sum(x)


from itertools import takewhile
house_numbers_sum = lambda lst: sum(takewhile(lambda n: n != 0, lst))


def house_numbers_sum(inp):
	(sm, i) = (0, 0)
	while inp[i] != 0:
		sm += inp[i]
		i += 1
	return sm


def house_numbers_sum(lst):
	result = 0
	for num in lst:
		if num == 0:
			return result
		result += num


def house_numbers_sum(inp):
	count = 0
	for item in inp:
		count += item
		if item == 0:
			break
	return count


def house_numbers_sum(inp):
	result = 0
	for i in inp:
		if i == 0:
			break
		result += i
	return result
	pass


def house_numbers_sum(inp):
	result = 0
	for n in inp:
		if n == 0:
			return result
		else:
			result += n
	return result


def house_numbers_sum(inp):
	a = inp.index(0)
	x = 0
	for i in range(a):
		x += inp[i]
	return x


def house_numbers_sum(inp):
	s = 0
	for e in inp:
		if e != 0:
			s += e
		else:
			return s


import unittest

def house_numbers_sum(inp):
	result = 0
	for ele in inp:
		if ele == 0:
			break
		result += ele
	return result

class TestHoseNumbersSum(unittest.TestCase):

	def test_should_return_0_when_given_inp_first_element_is_0(self):
		inp = [0, 1, 2, 3, 4, 5]
		actual = house_numbers_sum(inp)
		self.assertEqual(actual, 0)

	def test_should_return_sum_of_all_elemnt_when_given_inp_last_element_is_0(self):
		inp = [1, 2, 3, 4, 5, 0]
		actual = house_numbers_sum(inp)
		self.assertEqual(actual, 15)

	def test_should_return_sum_of_element_until_0_when_given_inp_has_0_in_middle(self):
		inp = [1, 2, 0, 4, 5]
		actual = house_numbers_sum(inp)
		self.assertEqual(actual, 3)


def house_numbers_sum(inp):
	x = inp.index(0)
	return sum((i for i in inp[:x]))


def house_numbers_sum(inp):
	res = 0
	for num in inp:
		if num == 0:
			return res
		res += num
	return -1


def house_numbers_sum(inp):
	i = 0
	ln = len(inp)
	res = 0
	while i < ln and inp[i] != 0:
		res += inp[i]
		i += 1
	return res


def house_numbers_sum(inp):
	add = 0
	for x in inp:
		if x == 0:
			return add
		add += x


def house_numbers_sum(inp):
	a = []
	for x in inp:
		if x != 0:
			a.append(x)
		else:
			break
	return sum(a)


def house_numbers_sum(inp):
	sum_ = 0
	for num in inp:
		if num != 0:
			sum_ += num
		else:
			break
	return sum_


def house_numbers_sum(inp):
	sum = 0
	for number in inp:
		sum += number
		if number == 0:
			break
	return sum


def house_numbers_sum(inp):
	i = 0
	out = 0
	while inp[i] != 0:
		out += inp[i]
		i += 1
	return out


def house_numbers_sum(inp):
	total = 0
	for i in inp:
		if i != 0:
			total += i
		else:
			return total


def house_numbers_sum(x):
	return sum(x[:x.index(0)])


def house_numbers_sum(inp):
	a = 0
	for n in inp:
		if n == 0:
			return a
		a += n
	return a


def house_numbers_sum(inp):
	tot = 0
	for x in inp:
		tot += x
		if x == 0:
			break
	return tot


def house_numbers_sum(inp):
	index = inp.index(0)
	return sum([a for a in inp[:index]])


def house_numbers_sum(inp):
	result = 0
	for i in inp:
		if i == 0:
			break
		else:
			result += i
	return result


def house_numbers_sum(inp):
	if inp == [] or inp[0] == 0:
		return 0
	return house_numbers_sum(inp[1:]) + inp[0]


def house_numbers_sum(lst):
	return sum(lst[:lst.index(0)])


def house_numbers_sum(inp):
	n = inp.index(0)
	new = inp[:n]
	return sum(new)


def house_numbers_sum(inp):
	zero_index = inp.index(0)
	total = 0
	for number in inp[:zero_index]:
		total += number
	return total


def house_numbers_sum(inp):
	result = 0
	for number in inp:
		result += number
		if number == 0:
			break
	return result


def house_numbers_sum(input):
	return sum(input[0:input.index(0)])


def house_numbers_sum(inp):
	s = 0
	for i in inp:
		if i != 0:
			s += i
		else:
			return s


def house_numbers_sum(inp):
	for i in range(len(inp)):
		if inp[i] == 0:
			new = inp[:i]
			return sum(new)


def house_numbers_sum(inp):
	if 0 not in inp:
		return sum(inp)
	else:
		return sum(inp[:inp.index(0)])


def house_numbers_sum(inp):
	hardstop = inp.index(0)
	house_sum = 0
	for i in range(0, hardstop):
		house_sum += inp[i]
	return house_sum


from itertools import takewhile

def house_numbers_sum(arr):
	return sum(takewhile(lambda x: x != 0, arr))


def house_numbers_sum(inp):
	for (idk, i) in enumerate(inp):
		if i == 0:
			return sum(inp[:idk])


def house_numbers_sum(inp):
	suma = 0
	for n in inp:
		if n == 0:
			break
		suma += n
	return suma