Every Other Sum
Add up the numbers of nums at indexes 0, 2, 4, and so on (every other one, starting with the first). Return the total as an int. Hint: slicing with a step, like nums[::2].
Example 1
nums [10,1,20,2,30]
returns 60
10 + 20 + 30 = 60.
Constraints
1 <= len(nums) <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Hottest DayBeginner
- Lower Triangle TotalBeginner
- Median ScoreBeginner
- Multiples Up ToBeginner
- Overlap CountBeginner
- Pass or FailBeginner
- Percent of TotalBeginner
- Pick ItemsBeginner