+ 1
Lists python
#a=1 b=2 c=3 d=4 e=5 f=6 g=7 h=8 i=9 j=10 k=11 l=12 m=13 n=14 o=15 p=16 q=17 r=18 s=19 t=20 u=21 v=22 w=23 x=24 y=25 z=26 list = ["i", "you", "everyone", "love", "coding"] print(max(list)) #you print(min(list)) #coding In which bases max and min of list (strings) are decided?
5 Respostas
+ 6
For strings max / min of list are decided by their ASCII values.
Like here : ASCII value of i = 105
ASCII value of y=121
ASCII value of e=101
ASCII value of l=108
ASCII value of c=99
So from above data u can see that max ASCII value is of y
and min is of c.
+ 3
String are compared sequentially from first char to last char. (Not by length )
"S" , "ABC" when we compare these 2 strings =>
at first Both 1st char of strings is compared .here "s" > "a" so "s">" abc" .
When both char gets equaled then comparison done comparing 2nd char,.... Like this . if both 2nd char are equal then 3rd char ... then 4th etc
"abcf" "ac" here both first char is equal so it compares 2nd char . as "c">" b" so "ac" > "abcf"
+ 1
Why only by first letter?
+ 1
Here in your list max value of first char is 'y' and min value is 'c'
So you get
max => you
min => coding.
+ 1
Thank you Md Sayed & 💖..₥łⱤ₳₵ⱠɆ..💖