The sum of numbers in a range

Report a typo

Your task here is to implement a simple algorithm that counts the sum of numbers from a list that belong to a specified range.

Input: the first line contains a list of integer numbers separated by spaces. The second line contains two integer numbers aa and bb such that aba \le b. The numbers are separated by a space as well. They represent the range.

Output: the sum of all elements xx of the list such that axba \le x \le b. If the list doesn't contain elements belonging to the specified range, output 00. See the example for more details.

Sample Input 1:

50 10 30 40 20
20 40

Sample Output 1:

90

Sample Input 2:

4 5 1 3 8
4 6

Sample Output 2:

9
Write a program in Python 3
def range_sum(numbers, start, end):
# ...


input_numbers = # ...
a, b = # ...
print(range_sum(input_numbers, a, b))
___

Create a free account to access the full topic