Skip to content

Commit d33dc34

Browse files
committed
Array Sum Inclusion
1 parent 9bb255b commit d33dc34

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"[python]":{
3+
"editor.defaultFormatter": "ms-python.black-formatter",
4+
"editor.formatOnSave": true,
5+
"editor.codeActionsOnSave": {
6+
"source.organizeImports": true
7+
}
8+
},
9+
"isort.args": ["--profile", "black"],
10+
}

main.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
empty_list = []
2+
3+
user_choice = None
4+
counter = 0
5+
6+
# Allow user to input numbers to the list
7+
while True:
8+
try:
9+
number = int(input(f"\nEnter a number {counter + 1}: "))
10+
empty_list.append(number)
11+
counter += 1
12+
except ValueError:
13+
print("\nSorry, you have to input an interger.")
14+
15+
user_choice = input("Do you wish to continue(Type 'Y' for yes. Any other input means no.)? ")
16+
if user_choice.lower() != "y":
17+
break
18+
19+
element_sum = sum(empty_list)
20+
21+
print(f"\nThe sum of the entered numbers is {element_sum}.")

0 commit comments

Comments
 (0)