scrimba
Learn Python
Lambda Functions Part 2
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Lambda Functions Part 2
AboutCommentsNotes
Lambda Functions Part 2
Expand for more info
index.py
run
preview
console

monty_python = ['John Marwood Cleese','Eric Idle','Michael Edward Palin','Terrence Vance Gilliam','Terry Graham Perry Jones', 'Graham Arthur Chapman']
def sort_names(name):
return name.split(' ')
monty_python.sort(key = lambda name:name.split(' ')[-1])
print(monty_python)
monty_python.sort(key= sort_names)
print(monty_python)
Console
"['Graham Arthur Chapman', 'John Marwood Cleese', 'Terrence Vance Gilliam', 'Eric Idle', 'Terry Graham Perry Jones', 'Michael Edward Palin'] "
,
"['Eric Idle', 'Graham Arthur Chapman', 'John Marwood Cleese', 'Michael Edward Palin', 'Terrence Vance Gilliam', 'Terry Graham Perry Jones'] "
,
/index.html
-6:19