1 class Solution: 2 def getDecimalValue(self, head: ListNode) -> int: 3 res = 0 4 lists = [] 5 while head != None: 6 lists.append(head.val) 7 head = head.next 8 pos = 0 9 for i in range(len(lists)-1,-1,-1): 10 res += lists[i] * (2 ** pos) 11 pos += 1 12 return res