File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 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 ('\n My 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 ('\n My list loop sum = ' + str (sum (empty_num_list ))) # non formatted string
20+
21+ print ('\n My list loop sum = {}' .format (str (sum (empty_num_list )))) # old formatted string
22+
23+ print (f'\n My list loop sum = { sum (empty_num_list )} ' ) # new formatted f' string
You can’t perform that action at this time.
0 commit comments