Write a function to create a linked list with given length and print the list after


Topic: Write a function to create a linked list with given length and print the list after

Solution

class Node:
    def __init__(self, val):
        self.val = val
        self.next = None
class LList:
    def __init__(self):
        self.head = None
def create_linked_list(*args):
    linked_list = LList()
    linked_list.head = Node(args[0])
    prev = linked_list.head
    for i in range(1, len(args)):
        entry = Node(args[i])
        prev.next = entry
        prev = entry
    return



List all Python Programs