MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Practicing Coding Interview Questions in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Exclude all the numbers from nums divisible by 3 or 5
print(nums)
fnums = filter(____)
print(list(fnums))
Edit dan Jalankan Kode