def partition(f, li, ys=[], zs=[]):
  if len(li) == 0: return ys, zs 
  x, *xs = li 
  if f(x): 
    return partition(f, xs, [*ys, x], zs)
  return partition(f, xs, ys, [*zs, x])
  
li = [1,2,3,4,5,6]  
print(partition(lambda x: x%2==1, li))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: