I won't write the details here. Please check for yourself. What I want to tell you is that you can do this! It is an introduction.
what is that? It is a feeling. For example, when sorting a 2D array, you can decide which column to sort by.
aa = [[1,2,3], [2,5,3], [3,3,4]]
When there is an array called, hmm, I want to sort in ascending order by the second number,
aa.sort(key=lambda x:x[1])
I can go. Find out more by yourself
The same guy as before. Other elements can be letters.
aa = [["a",2], ["c", 90], ["d", 8]]
Or something
aa.max(key=lambda x:x[1])
#["c",90]Should come back
Check this out for yourself
Use the set function. Remember this is so convenient It makes it a collective type. Details omitted
aa = [1,1,1,1,2,3,4,5]
set(aa)
#{1,2,3,4,5}
What is good about this is that you can see the number of elements without duplication.
len(set(aa))
#5
The set type is insanely helpful
Recommended Posts