Jump to content

Python Program Error in Finding Sum of Natural Numbers


gulshan212

Recommended Posts

Hello this is Gulshan Negi

Well, I am writing a program for finding sum of natural numbers but it shows some error at the time of execution.

Source Code: 

n = int(input("Enter the number:" ))
sum=0
if n > 1:
    for i in range(1,n+1):
        sum+=i:
    print("The sum of all natural number upto",n,"is ",sum)
else:
    print("Please Enter a value greater than 1")

I also checked and took teference from here, but i don't know what I am missing here. Can anyone give their suggestions on this.

Thanks

Link to comment
Share on other sites

Quote

Can anyone give their suggestions on this.

We are happy users of Delphi, so unfortunately we don't care very much about Python not working.

Python - even the name of the game tells one to stay away. Who knows, if it bites?

 

 

reticulated-python.jpg

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...