class Solution(object):
def getDecimalValue(self):
"""
:type head: ListNode
:rtype: int
"""
list = []
while head:
list.append(head.val)
head = head.next
list = list[::-1]
ans = 0
for i in range(len(list)):
ans += list[i] * (2 ** i)
return ans