def colname2num(s):
 s = s.upper()
 n = 0
 for c in s:
  assert ('A' <= c <= 'Z')
  n = ((((n * 26) + ord(c)) - ord('A')) + 1)
 return n

def colname2num ( s ) : s = s . upper ( ) n = 0 for c in s : assert ( 'A' <= c <= 'Z' ) n = ( ( ( ( n * 26 ) + ord ( c ) ) - ord ( 'A' ) ) + 1 ) return n
translate a column name to number .