See the flowchart below to understand how the code will work.
![](https://static.wixstatic.com/media/0f65e1_56b6c6f5b0c0481896168b4696af8409~mv2.png/v1/fill/w_106,h_80,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0f65e1_56b6c6f5b0c0481896168b4696af8409~mv2.png)
Code:
ListSum = [] #crate a empty list in Python
#takes input for number of elements in list
num = int(input("How many numbers you want to Add: "));
for n in range(num):
numbers=int(input("Enter numbers: "));
ListSum.append(numbers)
print("Sum of numbers in list: ",sum(ListSum))
output:
![](https://static.wixstatic.com/media/0f65e1_a85199e189e843b58dbd2cf0ada1b428~mv2.png/v1/fill/w_81,h_18,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0f65e1_a85199e189e843b58dbd2cf0ada1b428~mv2.png)
You can also add Negative number in the list. See the out below :
![](https://static.wixstatic.com/media/0f65e1_846f11d49e03400f971bbbc5ee6bde1e~mv2.png/v1/fill/w_77,h_18,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0f65e1_846f11d49e03400f971bbbc5ee6bde1e~mv2.png)
Read More:
The Tech Platform