Created
February 18, 2012 08:44
-
-
Save startling/1858281 to your computer and use it in GitHub Desktop.
constructing linked lists iteratively!
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
# the list so far; `tail` because we're starting at the end. | |
# None represents the empty list for now | |
tail = None | |
items = range(4) | |
# iterate through `items` backwards | |
for item in items[::-1]: | |
tail = (item, tail) | |
print tail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment