- 1

How to code "Find Numbers Divisible by Another Number" using lists inside funciton?

def myf(n,no,ele): list1 = [] for i in range(1,no): list1.append(ele) for i in list1: if (i%n == 0): print(i) n = int(input("enter a number: ")) no = int(input("enter total number of elements:")) print("enter numbers:") ele = int(input()) print("all numbers divisible by",n,"between 1-50 are:", myf(n,no,ele)) I am unable to run the above code, can you pls help me with the code and where I am going wrong?

28th Apr 2022, 5:05 AM
Ananya Rai
1 Odpowiedź
0
Also, put your code in Code Playground and edit your question with a link to it. And pls elaborate on "I am unable to run the above code" - what happens when you try? Be specific.
29th Apr 2022, 1:35 PM
Emerson Prado
Emerson Prado - avatar