A lambda function is a small anonymous function.
A lambda function can take any number of arguments, but can only have one expression.
s1 = 'GeeksforGeeks'
s2 = lambda func: func.upper()
print(s2(s1))
Output
GEEKSFORGEEKS
Syntax: lambda arguments : expression
A lambda function can include conditions using if statements.
Example:
# Example: Check if a number is positive, negative, or zero
n = lambda x: "Positive" if x > 0 else "Negative" if x < 0 else "Zero"
print(n(5))
print(n(-3))
print(n(0))
Output
Positive
Negative
Zero
Explanation: