0

Distinguing bewteen 'names' and 'name' on a function (Python)

I have been studying this python guide and it showed this function names = ['jaques', 'Ty', 'Mia', 'pui-wa'] print("longest name is:", max(names, key=lambda name: len(name))) print("names sorted case insensitive:", sorted(names, key=lambda name: name.lower())) Longest name is: jacques Names sorted case insensitive: ['jacques', 'Mia', 'pui-wa', 'Ty'] seems simple but I don't see where "name" is defined, and for python it should be different than "names" right?

26th Jul 2018, 3:43 AM
Ann
3 odpowiedzi
0
so when using lambda it assumes "name" refers to an element of the function?
26th Jul 2018, 4:33 AM
Ann
0
oh ok I noticed that part. I don't see how "name" relates to the elements of "names" tho. I suppose "key" connects them? thanks, I'm new at this
26th Jul 2018, 5:06 AM
Ann