Work's locally on python 2.7 and 3.5 but get an error here


  • 0
    C

    Hi,

    my code :

    def addTwoNumbers(self, l1, l2):
            return list(str(int("".join([str(x) for x in l1])) + int("".join([str(x) for x in l2])))[::-1])
    

    works fine on my local pc but when i try to run it here i get:

    Line 9: TypeError: 'ListNode' object is not iterable
    

    why?


  • 0
    W

    Locally you're giving lists to your addTwoNumbers, such like [2,4,3], to l1.

    But Leetcode is giving you ListNode instance, which has a self.next of another ListNode instance and so on, to your l1.

    The ListNode is a custom class, which is clearly not iterable.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.