Answer to Question #232603 in Python for Assignment

Question #232603
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.")





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS