+ 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)
2 Réponses
+ 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