One of
elif choice in ("m", "M"):
elif choice in "mM":
elif choice == 'm' or choice == 'M':
elif choice.lower() == 'm':
In terms of maintainability, the fourth alternative is better if you want to switch to case-insensitive comparison of multi-letter strings, since you need to provide all 2 N features in the 1st and 3rd alternatives. The second option only works for single-character strings.
With the 4th alternative it is also impossible to miss the case when you want to change 'm' to other letters.
In terms of efficiency, the second alternative is the most effective, and then the first, then the third and, finally, the fourth. This is due to the fact that the 3rd alternative includes more operations; and while calling functions and getting attribution is slow in Python, both make the 4th alternative relatively slow.
See http://pastie.org/1230957 for a disassembly and timeit result.
Of course, if you do not make this comparison 10 million times, there is no difference between each.
source share