Created
February 17, 2015 08:45
-
-
Save RadoRado/ff34aeb2e0241cc4abd2 to your computer and use it in GitHub Desktop.
Example for using main() and if __name__ check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def divisors(n): | |
| result = [] | |
| start = 1 | |
| while start < n: | |
| if n % start == 0: | |
| result = result + [start] | |
| start += 1 | |
| return result | |
| def main(): | |
| n = input("Enter n: ") | |
| n = int(n) | |
| print(divisors(n)) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment