sum of all integer between m and n in a loop Python 3 -
i having problems acquiring sum of integers between m
, n
. in code must input 2 integers m
, n
, calculate , display sum of integers m
n
.
the sum should calculated using loop repeatedly add numbers total , cannot use formula calculate result. code produced far displayed below:
m = int(input("enter number: ")) n = int(input("enter second number: ")) sum = 0 in range (m,n): m+n sum += print(i)
you should use range(m, n+1)
in order include n
in range.
for in range (m,n+1): sum += print(i) print(sum)
for example range(4,6)
give [4,5]
range(4,5)
give [4]
.
Comments
Post a Comment