codewars练习(1)

这篇博客介绍了如何在codewars上进行编程练习,目标是实现一个`array_diff`函数,该函数从一个列表中移除另一个列表中存在的所有值。文章提供了示例代码和测试用例,并讨论了编写生产质量代码的重要性,以及解决方案的投票机制。
摘要由CSDN通过智能技术生成

Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.

本kata的目标是实现一个差异函数,该函数从一个列表减去另一个列表并返回结果。

It should remove all values from list a, which are present in list b.

它应该从列表a中删除列表b中列出的所有值。

array_diff([1,2],[1]) == [2]

If a value is present in b, all of its occurrences must be removed from the other:

如果b列表中只有一个值,那a列表中出现这个值的元素都要删除

array_diff([1,2,2,2,3],[2]) == [1,3]

FUNDAMENTALS基本原理

ARRAYS数组

DATA TYPES数据类型

train

def array_diff(a, b):
    #your code here
    c=[]
    for index,val in enumerate(a):
        if val in b:
            continue
        c.append(val)
    return c

1.Tips: Kata Trainer

Welcome to the kata trainer! A few tips to get you started:

欢迎来到卡塔教练机!让你开始的几个小窍门:<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值