https://leetcode.com/problems/add-two-numbers/

# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution(object):

    def addTwoNumbers(self, l1, l2):
        """
        :type l1: ListNode
        :type l2: ListNode
        :rtype: ListNode
        """
        a = 0
        one = 0
        k = l1
        l1list = []
        while k is not None:
            l1list.append(k.val)
            k = k.next

        #print(l1list)
        for i in l1list:
            if a == 0:
                one += i
                a = 10
            else:
                one += i*a
                a = a*10
        two = 0
        b = 0
        k = l2
        l2list = []
        while k is not None:
            l2list.append(k.val)
            k = k.next

        for i in l2list:
            if b == 0:
                two += i
                b = 10
            else:
                two += i*b
                b = b*10
        #print(one)
        #print(two)
        sum = two+one

        sumlist = map(int, str(sum))

        #print(sumlist)
        ts = ListNode(sumlist.pop())
        n = ts

        j = []
        while len(sumlist) > 0:
            j = ListNode( sumlist.pop())
            n.next = j
            n = j

        sum = ts

        print
        return sum