In Python 2.6, I want to do:
f = lambda x: if x==2 print x else raise Exception() f(2) #should print "2" f(3) #should throw an exception
This clearly isn't the syntax. Is it possible to perform an if in lambda and if so how to do it?
if
lambda
← Назад к списку