Skip to content

Commit 83fa5c0

Browse files
Add files via upload
1 parent d3bf79f commit 83fa5c0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

The Empty List Python Program.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'''
2+
Create an empty list using a for loop and the append() function to create
3+
ten numbers from 1 to 10. After that, use the sum() function to add up all
4+
the numbers from 1 through 10.
5+
6+
Type and execute/run this Python program example below.
7+
'''
8+
value=1,11
9+
empty_num_list = []
10+
11+
# increment the empty list, using a for loop and the append() function.
12+
13+
for i in range(value[0],value[1]):empty_num_list.append(i)
14+
15+
print('\nMy list loop',empty_num_list) # view the scope contents of the empty list
16+
17+
# Try these three formatted print() functions to concatenate strings together.
18+
19+
print('\nMy list loop sum = '+str(sum(empty_num_list))) # non formatted string
20+
21+
print('\nMy list loop sum = {}'.format(str(sum(empty_num_list)))) # old formatted string
22+
23+
print(f'\nMy list loop sum = {sum(empty_num_list)}') # new formatted f' string

0 commit comments

Comments
 (0)