S="abcdefghijklmnopqrstuvwxyz" S.index(x)+1 It is converted to a character string up to the 26th with S, and converted to a number depending on the number of the actual alphabet. (There seems to be a better way ...)
x = [1,2,3,4,5] x.length (=5) (x.length -1) (=4) You can use it even with a short length.
Recommended Posts