0
は、ここに私のコードです:Pythonリンクリスト:次の値にアクセスするには?
class Node:
def __init__(self, cargo=None, next=None):
self.cargo = cargo
self.next = next
class LinkedList:
def __init__(self):
self.first = None
self.last = None
# then I declare a list and a node
S = LinkedList()
cel = Node
cel = S.first
今、私はリストに何かを入れたい:
'NoneType' object has no attribute 'val'
'NoneType' object has no attribute 'next'
問題がある:
n = 0
x = 0
while n < 5:
x = input()
cel.val = x
cel = cel.next
しかし、私はそれを示すエラーを取得しますか?
"val"という変数を指定しておらず、次に変数/整数を指定していないので、Noneが返されます。 –