Nickname Generator

Write a function, `nicknameGenerator` that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.

If the 3rd letter is a consonant, return the first 3 letters.

If the 3rd letter is a vowel, return the first 4 letters. 

If the string is less than 4 characters, return "Error: Name too short".

**Notes:**

- Vowels are "aeiou", so discount the letter "y".
- Input will always be a string.
- Input will always have the first letter capitalised and the rest lowercase (e.g. Sam).
- The input can be modified

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def nickname_generator(name):
	

Solutions:
def nickname_generator(name):
	return 'Error: Name too short' if len(name) < 4 else name[:3 + (name[2] in 'aeiuo')]


def nickname_generator(name):
	return name[:3 + (name[2] in 'aeiou')] if len(name) > 3 else 'Error: Name too short'


def nickname_generator(name):
	if len(name) < 4:
		return 'Error: Name too short'
	elif name[2] not in 'aeiou':
		return name[:3]
	elif name[2] in 'aeiou':
		return name[:4]


is_vowel = set('aeiou').__contains__

def nickname_generator(name):
	if len(name) < 4:
		return 'Error: Name too short'
	if is_vowel(name[2]):
		return name[:4]
	return name[:3]


def nickname_generator(name):
	VOWELS = 'aeiou'
	if len(name) < 4:
		return 'Error: Name too short'
	if name[2] in VOWELS:
		return name[:4]
	return name[:3]