Find the K-Beauty of a Number LeetCode solution in Python
1class Solution:2def divisorSubstrings(self, num: int, k: int) -> int:3# since integer has no length function, we convert our num into a str.4# Then we run a loop that goes until i+k-1 < len(numStr) and take5# n = int(numStr[i: i+k]); and if n!=0 and num%n==0 meaning6# num is divisible by n so we add 1 to k_beauty and return it in the end.78numStr = str(num)9i, k_beauty = 0, 01011while i + k - 1 < len(numStr):12n = int(numStr[i : i + k])13if n != 0 and num % n == 0:14k_beauty += 11516i += 11718return k_beauty