Python character list converted to number list

 y=["1","2","3","13"]

 If we want to take out the maximum value in the list y, we perform an operation such as print(max(y)), and it will print 3 instead of 13, because when the characters are compared, they are compared with a single character, and the result obtained first is not Not what we want, so how do we get the result we want?

This is that we only need to convert the list of characters into a list of numbers. We only need to use the map mapping function, x=list(map(int,y)), to convert the list of y characters into a list of x numbers.

x = list(map(int, y))

Guess you like

Origin blog.csdn.net/m0_52070737/article/details/128170833
Recommended