Can someone explain this....what is my mistake...that the sum is not come in a single line. It comes various tym. | Sololearn: Learn to code for FREE!

+2

Can someone explain this....what is my mistake...that the sum is not come in a single line. It comes various tym.

x=int(input("enter sum of number:")) sum=0 for i in range(1,x+1,1): sum+=i print("Sum of number from 1 to",x,"are:",sum)

4/14/2021 6:00:50 PM

Disha Jain

2 Answers

New Answer

+4

You need to print the output outside loop x=int(input("enter sum of number:")) sum=0 for i in range(1,x+1,1): sum+=i print("Sum of number from 1 to",x,"are:",sum)

+3

Okkkkk..... thanku Simba