DEV Community 👩‍💻👨‍💻


Posted on

divmod() in Python Learn --

The divmod() method in python takes two numbers and returns a pair of numbers consisting of their quotient and remainder

Output-- (3, 1) where 3 is quotient and 1 remainder.

This is Queation where divmod function used link--

Here problem solution

def addToArrayForm(self, A, K):
for i in range(len(A) - 1, -1, -1):
K, A[i] = divmod(A[i] + K, 10)
return [int(i) for i in str(K)] + A if K else A

Top comments (0)

Update Your DEV Experience Level:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠