The problem is the conditionals need to have an expression on both sides of the or otherwise it is treating the literal string as a boolean (which means it gets treated as true unless it is the empty string).
So you want to use:
if unit == 'L' or unit == 'l':
...
Similar for the other condition. Otherwise you can convert to upper or lowercase and only do one comparison.