I just write a simple method which returns a string based on the number in accepts as a parameter. I used
if/elif/esle here but I think for this simple scenario I wrote long code. I want to know is it possible to shorten this code in any way except using a lambda method. Also, I'm interested to know about the performance of
if/elif/else. Is there any other solution which can make faster this method?
def oneTwoMany(n): if n == 1: return 'one' elif n == 2: return 'two' else: return 'many'