from collections import deque
class Solution:
    # 返回从尾部到头部的列表值序列,例如[1,2,3]
    def printListFromTailToHead(self, listNode):
        # write code here
        result = deque()
        while listNode:
            result.appendleft(listNode.val)
            listNode = listNode.next
        return result