Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  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([]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement