> In python 3.4 how do I write a function that adds all the numbers within the range of [a,m]?

In python 3.4 how do I write a function that adds all the numbers within the range of [a,m]?

Posted at: 2014-12-18 
Python has a builtin called sum, so the code is simply:

a = [1,2,3,4]

print sum(a)

Try this:

#!/usr/bin/python

#Sum.py

#Chris Clarke

#08.10.2014

def Sum(i,j):

.... if i<=j:

.... .... return sum(x for x in range(i,j+1))

.... return 0



print (Sum(5,4))

print (Sum(5,5))

print (Sum(5,6))

print (Sum(5,7))

print (Sum(1,5))

# Note: I've used "...." to represent tabs, which Y!Answers removes.

lk;