# 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
Good job on this post. I liked how you wrapped the range function inside of a list. I think I learned something today 🙂
LikeLiked by 1 person
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.
LikeLiked by 1 person
Glad to hear it! 🙂
LikeLiked by 1 person