0

I have a below defined function:

x = 5

def foo():
    global x
    x = x * 2
    return x

foo()

Output: 10

Executing the above function foo() returns 10 and also updates the value of x as 10 since x is defined as global variable.

I want to achieve the same task using lambda function. How can I declare x as my global variable inside a lambda function?

martineau
  • 119,623
  • 25
  • 170
  • 301

0 Answers0