class Solution:
# @return a ListNode
def addTwoNumbers(self, l1, l2):
sum, rank = 0, 1
# finding value of sum by traversing both lists (rank: 1, 10, 100...)
while l1 is not None or l2 is not None:
if l1 is not None:
sum += l1.val * rank
l1 = l1.next
if l2 is not None:
sum += l2.val * rank
l2 = l2.next
rank *= 10
# creating result list
result = node = ListNode(sum%10)
sum//=10
while sum:
node.next = ListNode(sum%10)
node = node.next
sum//=10
return result
Sum up Python solution, please share your opinions about improving it


Hi Chester,
nope, it is floor division, regular operator in python:
https://docs.python.org/2/library/operator.html#mappingoperatorstofunctions
R