Skip to content

Instantly share code, notes, and snippets.

@blammothyst
Created February 27, 2014 20:14
Show Gist options
  • Save blammothyst/9258599 to your computer and use it in GitHub Desktop.
Save blammothyst/9258599 to your computer and use it in GitHub Desktop.
Code from Learn Python The Hardway(.org), ex 33
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