+ 1
How can I make a function that can filter numbers according to their multiples
It can filter numbers by their multiples
8 ответов
+ 4
There is already a filter function in python. Can you explain what is the expected input and output?
+ 6
if you will do this code, you need to decide:
- input numbers from x up to y if you have to create the numbers
- how to handle duplicates in the result. so 10 is a multiple of 2 and also of 5, or 30 is a multiple of 2, 3 and 5.
- if you get some numbers as list input, you can use filter or a for loop or a comprehension.
+ 4
Kintu Michael Evans , please do ask other people for doing your work. You should do a try by yourself first. Take your code and put it in playground and link it here. Thanks!
+ 4
What you have to do is use list comprehension.
E.g
Lets look for multiples of 3
>>>multiples_of_three = [i for i in range(20) if i%3==0]
>>>print(multiples_of_three)
+ 3
I am solving a code coach
+ 2
I want to make a function that can list multiples of 2,3,4 and 5
+ 2
Use the modulo operator. For example 8%2=0 this means that 8 is a multiple of 2.
+ 2
Make an example code