SHARE
TWEET

Untitled

a guest Jul 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def calc7(l):
  2.     if len(l) == 0:
  3.         return -1
  4.     sum = 0
  5.     for i, j in enumerate(l):
  6.         if j == 7 and i < len(l)-1:
  7.             l[i+1] *= 2
  8.         sum += j
  9.     return sum
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. print(calc7([1, 2]))
  19. print(calc7([3, 7]))
  20. print(calc7([7, 5, 6]))
  21. print(calc7([7, 9, 7, 9, 7, 9]))
  22. print(calc7([]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top