У меня очень трудное время понять, как правильно исправить мою функцию узла вставки. Я не получаю никаких ошибок, но я также не показываю список.Функция узла вставки Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
class Solution:
def display(self, head):
current = head
while current:
print current.data,
current = current.next
def insert(self, head, data):
self.head = head
new_node = Node(data)
if self.head is None:
self.head = new_node
else:
new_node.next = self.head
self.head = new_node
mylist = Solution()
T = int(input())
head = None
for i in range(T):
data = int(input())
head = mylist.insert(head, data)
mylist.display(head)
Может у исправить ваш отступы в 'while' цикле? –