Skip to content

Instantly share code, notes, and snippets.

@elpargo
Created March 15, 2014 01:25
Show Gist options
  • Save elpargo/9560463 to your computer and use it in GitHub Desktop.
Save elpargo/9560463 to your computer and use it in GitHub Desktop.
arr = [1,-1,4,2,1,5,-2]
negs = []
for i in arr:
if i<0:
negs.append(arr.remove(i))
if negs:
raise ValueError(negs)
else:
print sum(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment