Write function describeList which returns "empty" if the list is empty or "singleton" if it contains only one element or "longer"" if more.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def describeList(list):
	

Solutions:
def describeList(lst):
	return ['empty', 'singleton', 'longer'][min(len(lst), 2)]


def describeList(list):
	return 'empty' if not list else 'singleton' if len(list) == 1 else 'longer'


def describeList(list):
	return ['empty', 'singleton', 'longer'][len(list[:2])]


def describeList(list):
	return {0: 'empty', 1: 'singleton'}.get(len(list), 'longer')


def describeList(lst):
	if lst:
		if len(lst) == 1:
			return 'singleton'
		return 'longer'
	return 'empty'


def describeList(list):
	if not list:
		return 'empty'
	elif len(list) == 1:
		return 'singleton'
	return 'longer'


def describeList(list):
	if len(list) == 1:
		return 'singleton'
	elif len(list) > 1:
		return 'longer'
	else:
		return 'empty'


def describeList(a):
	return 'empty' if not a else 'singleton' if len(a) == 1 else 'longer'