def sum_two_lists(self, llist):
first = self.head
second = llist.head
carry = 0
sum_llist = LinkedList()
while first or second:
f = first.data if first is not None else 0
s = second.data if second is not None else 0
summ = f + s + carry
carry = summ // 10
sum_llist.append(summ % 10)
first = first.next if first is not None else None
second = second.next if second is not None else None
return sum_llist
Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers