Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. def calc7(arr):
  2. if len(arr) == 0:
  3. return -1
  4. else:
  5. is_7 = False
  6. ret = 0
  7. for i in arr:
  8. if is_7:
  9. ret += i * 2
  10. is_7 = False
  11. else:
  12. ret += i
  13. if i == 7:
  14. is_7 = True
  15. return ret
  16.  
  17. print(calc7([1,2]))
  18. print(calc7([3,7]))
  19. print(calc7([7,5,6]))
  20. print(calc7([7,9,7,9,7,9]))
  21. print(calc7([]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement