Skip to content

Instantly share code, notes, and snippets.

@pinkpretty
Created September 19, 2016 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkpretty/f3d4773c334ae24a1dc31f6f8a543ba2 to your computer and use it in GitHub Desktop.
Save pinkpretty/f3d4773c334ae24a1dc31f6f8a543ba2 to your computer and use it in GitHub Desktop.
'''
This is the 4th exercise of PracticePython
'''
'''
Create a program that asks the user for a number and then prints out a list of all the divisors of that number. (If you don’t know what a divisor is, it is a number that divides evenly into another number.
For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)
'''
#mycode
while True:
try:
number = int(input("Enter a number"))
divisors = [item for item in range(1,number+1) if(number % item) == 0]
print("The divisors are:",divisors)
exit(0)
except ValueError:
print ("Please input a number")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment