Descriptive quantity (one, two, many) from number 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'
You can instead use a dictionary to define your n values:

nums = {1: 'one', 2: 'two'}


Then, when you want to use this, you can use .get(). .get() has a default argument which is returned when a dict doesn't have a key you've requested; here we use 'many' to be returned.

def oneTwoMany(n):
    nums = {1: 'one', 2: 'two'}
    return nums.get(n, 'many')


If you really want to be concise you can stop defining nums:

def oneTwoMany(n):
    return {1: 'one', 2: 'two'}.get(n, 'many')


As an aside to the downvoters of the question; it may be a simple question but I don't see how it breaks any rules.

EDIT: incorporating some other answers which (quite rightly) suggest catching certain invalid inputs.

def oneTwoMany(n):
    if type(n) is not int:
        raise TypeError('Invalid input, value must be integer')
    elif n &lt; 1:
        raise ValueError('Invalid input, value is below 1')
    else:
        return {1: 'one', 2: 'two'}.get(n, 'many')