Skip to content

Instantly share code, notes, and snippets.

@kevin-weitgenant
Created August 2, 2016 12:58
Show Gist options
  • Save kevin-weitgenant/97fac6287eea7274dba6f90cda3ad6bb to your computer and use it in GitHub Desktop.
Save kevin-weitgenant/97fac6287eea7274dba6f90cda3ad6bb to your computer and use it in GitHub Desktop.
practicepython.org Exercise 04
# 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.)
a = []
number = int(input("Enter a number:"))
x = number
for _ in range(number):
resultado = number % x
x = x - 1
if resultado == 0:
a.append(x+1)
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment