Created
March 29, 2020 18:48
-
-
Save Deep18-03/96282da2bde9cd1d0d97e48d15a6dacf to your computer and use it in GitHub Desktop.
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.
This file contains 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
''' | |
1.create a empty list | |
2.ask user for the number num | |
3.for loop to iterate up to that num | |
4.find all divior of that number using if | |
5.add all divsior in list | |
6.print the list | |
''' | |
lst=[] | |
num=int(input("enter the number")) | |
for i in range(1,num+1): | |
if num%i==0: | |
lst.append(i) | |
print(lst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment