In isolation using 96 is fine, but structuring it the way Kosmarik proposed is more extensible in the future (for example, if you wanted to extend the function to return a character's position relative to any other character, it'd be easier to implement that by just replacing 'a' with a function argument).
why would it be better? Every dev knows the ascii table and where to look it up in seconds and everyone who reads the solution instantly knows why to subtract exactly 96.
Your solution is much worse to read
In isolation using
96
is fine, but structuring it the way Kosmarik proposed is more extensible in the future (for example, if you wanted to extend the function to return a character's position relative to any other character, it'd be easier to implement that by just replacing'a'
with a function argument).why would it be better? Every dev knows the ascii table and where to look it up in seconds and everyone who reads the solution instantly knows why to subtract exactly 96.
Your solution is much worse to read
I was gunna do math.floor I think but no need bc of floor division.