--Utilisez `` divmod```
n = 3
cnt = 10
quot, mod = divmod(cnt, n)
#quotient
print(quot)
#Surplus
print(mod)
>>> #quotient
>>>
>>> print(quot)
3
>>> #Surplus
>>>
>>> print(mod)
1
>>>
// ``
% ''n = 3
cnt = 10
#quotient
print(cnt // n)
#Surplus
print(cnt % n)
>>> #quotient
>>>
>>> print(cnt // n)
3
>>> #Surplus
>>>
>>> print(cnt % n)
1
>>>
Recommended Posts