Created
October 5, 2022 12:42
-
-
Save mjcarnaje/96098c2f99b1f96125f08db53233098f to your computer and use it in GitHub Desktop.
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
class Link: | |
def __init__(self): | |
self.value = None | |
self.nextLink = None | |
def setValue(self, value): | |
self.value = value | |
def setNext(self, nextLink): | |
self.nextLink = nextLink | |
head = Link() | |
head.setValue(1) | |
head.setNext(None) | |
current = head | |
for i in range(2, 21): | |
newLink = Link() | |
newLink.setValue(i) | |
newLink.setNext(head) | |
current.setNext(newLink) | |
current = newLink | |
current = head | |
for i in range(0, 21): | |
print(current.value) | |
current = current.nextLink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment