Answers for "value isn't remembered in lambda python"

0

value isn't remembered in lambda python

def main():
    d = {}
    for x in [1,2]:
        d[x] = lambda x=x: print(x)

    d[1]()
    d[2]()


if __name__ == '__main__':
    main()

>>> 
1
2
Posted by: Guest on September-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language