# Create a program that asks the user for a number
# and then prints out a list of all the divisors of that number.

num = int(input("Enter a number"))
check = list(range(1, num+5))

for number in check:
    if num % number == 0:
        print(number)

 

num – takes the input of the user for the number.

check – is a list which contains all the elements for the range defined.

Then we have a loop which starts with the element in check list checking out all the possible values in the list. *haha.. did you get the pun?!*

Then we have an if loop which checks whether the number inputted by the user is divisible completely by any of the number in the range which is defined in check.

Finally we print out all the values of the number which are divisible completely. It took me a while to figure what to print out.

FYI: Range can be defined anything by you. Doesn’t necessarily have to be +5.

PPPS: I wrote all my PS’s before the explanation of the code.

PS: Phew! No one holla-ed me but I still gave it anyway. I know I suck at explanations. I’ll definitely improve myself.

PPS: I personally find myself hilarious which is huge misconception and is generally agreed by everyone in my circle. You can definitely ignore all the puns in-spite of the fact that I know you would be laughing and saying things like ‘oh-so-genius with her jokes’. Just saying. #ignore

3 thoughts on “Day 6: Create a program that asks the user for a number and then prints out a list of all the divisors of that number.

    1. Thank you! I think it’s only because of your kind words that I feel motivated to come and do something! 🙂 I actually do enjoy your posts as well.

      Liked by 1 person

Leave a comment