Lambda functions (lambda)

A Python lambda function is a small function that can take any number of arguments, but the return must only be in one expression. lambda functions are unnamed.

Essentially, functions like this:

def func(*args):
    return [expression]

To this:

lambda [args]: [expression]

An example:

import random

a = list(range(1, 10001)) # is a list that has 10000 elements starting from 1 and ending in 10000

random.shuffle(a) # randomly shuffles a

#python #python/features