Ruby and Python code to sume array/list