Quick actions

cmd+k|ctrl+k

Navigation

Languages

Linked List in Python

Snippet info

Language

Python

Visibility

public

Author

fakhryslacker

Created

2024-12-03T14:01:17.813143Z

Updated

2024-12-03T14:01:32.44164Z

class Node:
    def __init__(self, name=None):
        self.name = name
        self.next = None

def main():
    current = None
    first = Node()
    second = Node()
    third = Node()

    first.name = "James Gosling"
    first.next = second
    second.name = "2023"
    second.next = third
    third.name = "Sun Microsystem"
    third.next = None

    current = first
    while current is not None:
        print(current.name)
        current = current.next

if __name__ == "__main__":
    main()
INFO