This Python Program **Generates the Sum of N Numbers**. This Python program obtains the Nth number from the user and calculates its sum till the Nth number.

Here is source code of the Python Program to Generate the Sum of N Numbers.

1 2 3 4 5 6 7 8 9 10 11 12 |
num = int(input("Enter a number: ")) if num < 0: print("Enter a positive number") else: sum = 0 # use while loop to iterate un till zero while(num > 0): sum += num num -= 1 print("The sum is",sum) |

**Output:**