Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def calc7(vals):
  2. calk = 0
  3. luckky = 1
  4.  
  5. for val in vals:
  6. calk += val * luckky
  7. if val == 7:
  8. luckky = 2
  9. else:
  10. luckky = 1
  11.  
  12. if calk == 0:
  13. calk = -1
  14.  
  15. return calk
  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