SUMUNZ - Sum Until 0
Given a list, calculates the sum of all the elements in the list that precede the first 0. If the 0 is not present the result will be the sum of all the elements. If the list is empty, return 0.
NOTE: To read the input list you can, for example, use the lis = eval(input()) command which stores the input list in the lis variable.
Input
A list of number
Output
the sum of all the elements in the list that precede the first 0. If the 0 is not present the result will be the sum of all the elements. If the list is empty, return 0
Example
Input: [3,6,7,2,0,4,0,45,32,0] Output: 18
Added by: | giorgio.piccardo |
Date: | 2018-09-20 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | NCSHARP JULIA PYPY3 PYTHON3 |