int.sum_digits()

This commit is contained in:
Stefan Harmuth 2023-07-08 14:12:25 +02:00
parent b0a8388a8b
commit ec64dce347
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
bs4~=0.0.1
beautifulsoup4==4.11.1
fishhook~=0.2.5
pygame~=2.4.0
requests==2.28.1
setuptools==65.6.3

View File

@ -183,4 +183,15 @@ def intersection(self, *args) -> str:
@hook(str)
def __and__(self, *args) -> str:
return self.intersection(*args)
return self.intersection(*args)
@hook(int)
def sum_digits(self) -> int:
s = 0
num = self
while num > 0:
s += num % 10
num //= 10
return s