To find sum of natural numbers in python, you have to ask from user to enter the total number of term upto which he/she want to find the sum of all natural numbers upto the desired term and then print the summation result as output as shown in the program given below.
Following python program ask from user to enter the limit to find the sum of all natural numbers upto that limit:
# Python Program - Find Sum of Natural Numbers while True: print("Enter '0' for exit.") num = int(input("Upto which number ? ")) if num == 0: break elif num < 1: print("Please, enter a positive number...") else: sum = 0 while num > 0: sum += num num -= 1 print("Sum = ", sum)
Here is the sample run of the above Python program to illustrate how to find and print sum of natural numbers: