Skip to main content
Data Science Wizardry Blog by Attila Vajda

Solving puzzles while listening to world music.

>>> swap=lambda a,b:b,a
>>> swap(1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable

"The syntax to create a lambda function is lambda [parameters]: expression":

>>> swap=lambda a,b:(b,a)
>>> swap(a,b)
(2, 1)

Solving coding puzzles is fun so far. I am learning a ton from doing the "Coffee Break" books, and making custom puzzles to everything I learn in collaboration with a computer agent. It also connects to the neuroplasticity work of building awesome brain connectivity.