Home > other >  Python for solution
Python for solution

Time:10-03

List of known objects x=[' 11 ', '2', '3'], the expression of Max (x) has a value of '3', why? Why not '11'

CodePudding user response:

Because it is a string, if x=[11, 2, 3], Max (x) is the 11,
You can also use Max (map (int x))

CodePudding user response:

reference 1/f, ice all over the sky the wind response:
because it is a string, if x=[11, 2, 3], Max (x) is the 11,
You can also use Max (map (int x))

Still don't understand, why compare strings is the biggest "3"

CodePudding user response:

refer to the second floor qq_43967964 response:
Quote: refer to 1st floor ice all over the sky the wind response:
because it is a string, if x=[11, 2, 3], Max (x) is the 11,
You can also use Max (map (int x))

Still don't understand, why compare strings is the biggest "3"


Because string comparison is to compare first initials, '11' is the first letter of '1', '3' is the first letter of '3', '3' so big

CodePudding user response:

This way, it got it, thank you!

CodePudding user response:

ice reference 3 floor of wind response:
Quote: refer to the second floor qq_43967964 response:

Quote: refer to 1st floor ice all over the sky the wind response:
because it is a string, if x=[11, 2, 3], Max (x) is the 11,
You can also use Max (map (int x))

Still don't understand, why compare strings is the biggest "3"


Because string comparison is to compare first initials, '11' is the first letter of '1', '3' is the first letter of '3', '3' so big

This way, it got it, thank you!
  • Related