SHARE
TWEET

Untitled

a guest Jul 17th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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([]))
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