SHARE
TWEET

Untitled

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