DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,503 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
gaurbprajapati
gaurbprajapati

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
`
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

Oldest comments (0)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.