given a string columntitle that represents the column title in an excel sheet return its corresponding column number exceltitletocolumna 1 exceltitletocolumnb 2 exceltitletocolumnab 28 exceltitletocolumnz 26 given a string column_title that represents the column title in an excel sheet return its corresponding column number excel_title_to_column a 1 excel_title_to_column b 2 excel_title_to_column ab 28 excel_title_to_column z 26
def excel_title_to_column(column_title: str) -> int:
    
    assert column_title.isupper()
    answer = 0
    index = len(column_title) - 1
    power = 0

    while index >= 0:
        value = (ord(column_title[index]) - 64) * pow(26, power)
        answer += value
        power += 1
        index -= 1

    return answer


if __name__ == "__main__":
    from doctest import testmod

    testmod()