Conditional statement in a one line lambda function in python?
Apologies if this has been asked before, but I couldn't see it anywhere. Essentially I've come across a scenario where i need to make use of an if statement inside a lambda function. What makes it difficult is that ideally it needs to be in a single line of code (if thats even possible?) Normally, i would write this: T = 250 if (T > 200): rate = 200*exp(-T) else: rate = 400*exp(-T) return (rate) However i need it to look like this: rate = lambda(T) : if (T>200): return(200*exp(-T)); else: return(400*exp(-T)) I realize the easier thing to do would to take the decision making outside of the