码迷,mamicode.com
首页 > 其他好文 > 详细

【Kata Daily 191012】Find numbers which are divisible by given number

时间:2019-10-12 11:28:26      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:func   pytho   python   dai   ble   number   function   UNC   span   

题目:

Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor.

Example

divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]

 

解题方法:

def divisible_by(numbers, divisor):
    return [x for x in numbers if x%divisor == 0]

 

【Kata Daily 191012】Find numbers which are divisible by given number

标签:func   pytho   python   dai   ble   number   function   UNC   span   

原文地址:https://www.cnblogs.com/bcaixl/p/11658775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!