Write a function to print the count of divisor using list comprehension


Topic: Write a function to print the count of divisor using list comprehension

Solution

def divisor_using_list(num: int):
    """
    function to count the number of divisor using list comprehension.
    """
    if isinstance(num, int):
        count = [i for i in range(1,num+1) if not num%i]
        print(f'Number of divisor is {count}')
    else:
        raise ValueError('Invalid Input')



List all Python Programs