Advertisement
furas

Python - add two-digits numbers

Mar 21st, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def solution(A):
  2.    
  3.     result = 0
  4.    
  5.     for number in A:
  6.         if 9 < number < 100 or -100 < number < -9:
  7.             result += number
  8.  
  9.     return result
  10.  
  11. # --- tests ---
  12.  
  13. data = [
  14.   [ [1, 1000, 80, -91], -11 ],
  15.   [ [2, 25, 300, 52, 10], 87 ],
  16. ]    
  17.  
  18. for A, correct_result in data:
  19.     result = solution(A)
  20.     print(result, correct_result, result == correct_result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement