Advertisement
Guest User

Untitled

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