Skip to content

Commit 9c4f5d0

Browse files
committed
extra credit - replaced while loop with a function
1 parent a2f4c30 commit 9c4f5d0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ex33.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
i = 0
2-
numbers = []
1+
def add_numbers(max):
2+
i = 0
3+
numbers = []
4+
while i < max:
5+
print "At the top i is %d" % i
6+
numbers.append(i)
37

4-
while i < 6:
5-
print "At the top i is %d" % i
6-
numbers.append(i)
8+
i = i + 1
9+
print "Numbers now: ", numbers
10+
print "At the bottom i is %d" % i
711

8-
i = i + 1
9-
print "Numbers now: ", numbers
10-
print "At the bottom i is %d" % i
12+
return numbers
1113

14+
numbers = add_numbers(10)
1215

1316
print "The numbers: "
1417

0 commit comments

Comments
 (0)