Write a Python program that takes a number from the user and prints the divisors of that
number and then print how many divisors were there. [The input number has to be an
INTEGER]
Input:
6
Output:
1, 2, 3, 6
Total 4 divisors.
1
Expert's answer
2021-09-06T14:14:09-0400
n=int(input())
divisors = ([i for i in range(1,n+1) if not n % i])
divisorsStr = [str(element) for element in divisors]
print(",".join(divisorsStr))
print(f"Total {len(divisors)} divisors.")
Comments
Leave a comment