Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Excel Column Number by jullios1104
from string import ascii_uppercase
def column_number(name: str) -> int:
D=dict(zip(ascii_uppercase, range(1,27)))
i,N=len(name)-1,0
while name:
a, *name=name
N=N+D[a]*26**i
i-=1
return N
print("Example:")
print(column_number("ZY"))
# These "asserts" are used for self-checking
assert column_number("A") == 1
assert column_number("Z") == 26
assert column_number("AB") == 28
assert column_number("ZY") == 701
print("The first mission is done! Click 'Check' to earn cool rewards!")
Oct. 25, 2023