For calculating the sum I used a while-loop. This one is nested in an if-else statement, so that the program can tell the user when we confused the lower with the upper bound.

This is my code:

print("I will calculate the sum of numbers in a range you select.")

numLow = numLow1 = int(input("What is the lower bound? "))
numUp = int(input("What is the upper bound? "))

x = int(numLow)

if numLow <= numUp :
    while numLow != numUp :
        numLow = numLow + 1
        x = x + numLow
    print("The sum of numbers in the range between", numLow1,"and",numUp,"is",x)
else:
    print("You didn't type in the numbers in the right order.")
        
print(numCom,"was the right number!")
print("You needed",attempt,"attempts.")

CC BY 4.0 WSQ07 – Sum of Numbers by finntec is licensed under a Creative Commons Attribution 4.0 International License.