. Advertisement .
..3..
. Advertisement .
..4..
I would love to add numbers in python using for loop but I don’t know what is the best way to do it yet. Can you share with me more about the related knowledge?
Here is our case study:n = input("Enter Number to calculate sum")
n = int (n)
sum = 0
for num in range(0, n+1, 1):
sum = sum+num
print("SUM of first ", n, "numbers is: ", sum )
Consequently, if you want to test whether it works or not, use the suggested ways here.