python3解法 借助reversed函数反转列表或者列表自身特性直接反转

# -*- coding:utf-8 -*-
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None
class Solution:
    # 返回ListNode
    def ReverseList(self, pHead):
        # write code here
        head = ListNode(0)
        p = head
        tmp_list = []
        while pHead is not None:
            tmp_list.append(pHead.val)
            pHead = pHead.next
        # for item in tmp_list[::-1]:
        for item in reversed(tmp_list):
            p.next = ListNode(item)
            p = p.next
        return head.next