Created
February 27, 2014 20:14
-
-
Save blammothyst/9258599 to your computer and use it in GitHub Desktop.
Code from Learn Python The Hardway(.org), ex 33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = 0 | |
numbers = [] | |
while i < 6: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
i += 1 | |
print "Numbers now: ", numbers | |
print "At the bottom i is %d" % i | |
print "The numbers: " | |
for num in numbers: | |
print num | |
def init_list(max,step=1): | |
i = 0 | |
numbers = [] | |
while i < max: | |
print "At the top i is %d" % i | |
numbers.append(i) | |
i += step | |
print "Numbers now: ", numbers | |
print "At the bottom i is %d" % i | |
return numbers | |
numbers = init_list(10, 5) | |
print "The numbers: " | |
for num in numbers: | |
print num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment