class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def printListFromTailToHead(self , listNode) :
temp=[]
while listNode:
temp.append(listNode.val)
listNode=listNode.next
temp.reverse()
return temp
listnode=ListNode(1)
listnode.next=ListNode(2)
listnode.next.next=ListNode(3)
listnode.next.next.next=ListNode(4)
res=Solution()
res=res.printListFromTailToHead(listnode)
print(res)
09-26
1332