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)

AWS Industries LIVE! Stream

Business benefits of the cloud

Join AWS experts and tech leaders as they discuss the business impact of the cloud on Industries LIVE!

Learn More

👋 Kindness is contagious

Dive into this insightful write-up, celebrated within the collaborative DEV Community. Developers at any stage are invited to contribute and elevate our shared skills.

A simple "thank you" can boost someone’s spirits—leave your kudos in the comments!

On DEV, exchanging ideas fuels progress and deepens our connections. If this post helped you, a brief note of thanks goes a long way.

Okay