Excel Sheet Column Number
- python
- math
- strings
Problem URL:Excel Sheet Column Number
My Solution
Python
import string
def titleToNumber(columnTitle: str) -> int:
str_list = string.ascii_uppercase[:26]
column_num = 0
letters = list(reversed(columnTitle))
for index, letter in enumerate(letters):
column_num += (str_list.index(letter)+1)*(26**index)
return column_num
Let's Connect
Twitter •GitHub •LinkedIn