What about this? lambda x, y: a = sum(x)/len(x); b = sum(y)/len(y); (a+b)/2;; The double-semicolon notation can also replace indentation for grouping of statements: y=0 for x in list: y=2*y+x if y%13==0: y=12;;;;