DEV Community

gaurbprajapati
gaurbprajapati

Posted on

2 1

divmod() in Python Learn --

The divmod() method in python takes two numbers and returns a pair of numbers consisting of their quotient and remainder
`
print(divmod(10,3))

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

This is Queation where divmod function used link--
https://leetcode.com/problems/add-to-array-form-of-integer/

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)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay