SHARE
TWEET

Untitled

a guest Jul 17th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def calc7(num_list):
  2.     if len(num_list) == 0:
  3.         return -1
  4.    
  5.     sum = 0
  6.     lucky_flg = False
  7.  
  8.     for i in num_list:
  9.         if lucky_flg:
  10.             sum += 2 * i
  11.         else:
  12.             sum += i
  13.         if i == 7:
  14.             lucky_flg = True
  15.         else:
  16.             lucky_flg = False
  17.            
  18.     return sum
  19.    
  20.    
  21. print(calc7([1, 2]))
  22. print(calc7([3, 7]))
  23. print(calc7([7, 5, 6]))
  24. print(calc7([7, 9, 7, 9, 7, 9]))
  25. 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