Quiz Catalog

Catalog of quizzes

lst = [-4, 0, 2, '', 7, 'a', ' ', -4]

b = list(filter(None, lst))

print(b)
[-4, 2, 7, 'a', ' ', -4]
  • build-in/filter
  • build-in/list
  • list/literal

def check(x):
  if x % 2 == 0:
    return 1


lst = [2, 1, 4, 5, 3]

a = list(filter(check, lst))

print(a)
[2, 4]
  • build-in/filter
  • build-in/list
  • expression/operation/modulo
  • list/literal

func = lambda x : x % 2 == 0
nums = filter(func, range(17))
print(len(nums) + min(nums))
TypeError: object of type 'filter' has no len()
  • build-in/filter