Skip to content

Instantly share code, notes, and snippets.

@niitsken
Created July 9, 2016 01:24
Show Gist options
  • Save niitsken/4a2175132de4cd4122303afced2a2a9e to your computer and use it in GitHub Desktop.
Save niitsken/4a2175132de4cd4122303afced2a2a9e to your computer and use it in GitHub Desktop.
def sum4(list_integer):
sum = 0
i = 0
length = len(list_integer)
while i < length:
sum += list_integer[i]
if list_integer[i] == 4: i += 1
i += 1
return sum
print sum4([1, 2])
print sum4([3, 4])
print sum4([4, 5, 6])
print sum4([4, 9, 4, 9, 4, 9])
print sum4([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment