开始使用免费开始使用

The filter() function

Let's do some filtering! You will be given three corresponding tasks you have to complete. Use lambda expressions! And remember: the filter() function keeps all the elements that are mapped to the True value.

The variables nums, string and spells are available in your workspace.

本练习是课程的一部分

Practicing Coding Interview Questions in Python

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Exclude all the numbers from nums divisible by 3 or 5
print(nums)
fnums = filter(____)
print(list(fnums))
编辑并运行代码