Hi guys,
i am a newbie in Python. I have a problem with an OOP issue. This is my code
Thanks to community for your help.
Walter
i am a newbie in Python. I have a problem with an OOP issue. This is my code
class Solution: def __init__(self): self.head = None def addTwoNumbers(self, lista1, lista2): carry = 0 Current1 = lista1.head Current2 = lista2.head ResultCurrent = self.head while (Current1.next != None and Current2.next != None ): if (Current1.data)+(Current2.data) > 10: datanew = Current1.data + Current2.data - 10 + carry carry = 1 ResultCurrent.insert(datanew) else: datanew = Current1.data + Current2.data + carry ResultCurrent.insert(datanew) carry = 0 Current1 = Current1.next Current2 = Current2.next ResultCurrent = ResultCurrent.nextFollow the main:
def main(): LL1 = LinkedList() LL1.insert(3) LL1.insert(4) LL1.insert(5) LL1.printLL() LL2 = LinkedList() LL2.insert(6) LL2.insert(7) LL2.insert(8) LL2.printLL() result = Solution() result.addTwoNumbers(self, LL1, LL2) result.printListLinked()When i try to run this code i have an errore regarding the first argument of method of Solution class addTwoNumbers.
Thanks to community for your help.
Walter
Larz60+ write May-19-2022, 08:16 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.