Python Program to Read a Number n and Print the Series “1+2+…..+n= “
n=int(input("Enter a number: "))
a=[]
for i in range(1,n+1):
print(i,sep=" ",end=" ")
if(i<n):
print("+",sep=" ",end=" ")
a.append(i)
print("=",sum(a))
print()
Output
Enter a number: 4
1 + 2 + 3 + 4 = 10
