In this exercise, you will have to create a function named tiyFizzBuzz. This function will take on a string parameter and will return that string with some characters replaced, depending on the value:

- If a letter is a upper case consonants, replace that character with "Iron".
- If a letter is a lower case consonants or a non-alpha character, do nothing to that character
- If a letter is a upper case vowel, replace that character with "Iron Yard".
- If a letter is a lower case vowel, replace that character with "Yard".

Ready?

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def tiy_fizz_buzz(string):
	

Solutions:
def tiy_fizz_buzz(s):
	return ''.join((('Iron ' * c.isupper() + 'Yard' * (c.lower() in 'aeiou')).strip() or c for c in s))


def tiy_fizz_buzz(strin):
	strin = list(strin)
	for (i, char) in enumerate(strin):
		if char in 'AEIOU':
			strin[i] = 'Iron Yard'
		elif char in 'aeiou':
			strin[i] = 'Yard'
		elif char in 'QWRTYPSDFGHJKLZXCVBNM':
			strin[i] = 'Iron'
	return ''.join(strin)


def tiy_fizz_buzz(string):
	return ''.join(('Iron Yard' if c in 'AEIOU' else 'Yard' if c in 'aeiou' else 'Iron' if c.isupper() else c for c in string))


def tiy_fizz_buzz(s):
	uv = [chr(x) for x in [65, 69, 73, 79, 85]]
	lv = [chr(x) for x in [97, 101, 105, 111, 117]]
	u = [chr(x) for x in range(66, 91)]
	return ''.join(['Iron Yard' if x in uv else 'Iron' if x in u else 'Yard' if x in lv else x for x in list(s)])


def translate(x):
	if x.isupper():
		if x not in 'AEIOU':
			return 'Iron'
		else:
			return 'Iron Yard'
	elif x not in 'aeiou' or not x.isalpha():
		return x
	else:
		return 'Yard'

def tiy_fizz_buzz(string):
	return ''.join((translate(c) for c in string))


tiy_fizz_buzz = lambda x: ''.join((('Iron' * e.isupper() + ' ' + 'Yard' * (e.lower() in 'aiueo')).strip() or e for e in x))


def tiy_fizz_buzz(string):
	new_string = ''
	for i in string:
		if i.isupper():
			new_string += 'Iron'
			if i in 'AEIOU':
				new_string += ' Yard'
		elif i in 'aeiou':
			new_string += 'Yard'
		else:
			new_string += i
	return new_string


def tiy_fizz_buzz(string):
	r = lambda i: {i in 'euioa': 'Yard', i in 'EUIOA': 'Iron Yard', i in 'QWRTYPSDFGHJKLZXCVBNM': 'Iron', not i in 'euioaEUIOAQWRTYPSDFGHJKLZXCVBNM': i}[True]
	return ''.join([r(i) for i in string])


import re

def ironyarder(m):
	lst = []
	if m[0].isupper():
		lst.append('Iron')
	if m[0].lower() in 'aeiou':
		lst.append('Yard')
	return ' '.join(lst)

def tiy_fizz_buzz(s):
	return re.sub('[A-Zaeiou]', ironyarder, s)