When provided with a String, capitalize all vowels

For example:

Input : "Hello World!"

Output : "HEllO WOrld!"

Note: Y is not a vowel in this kata.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def swap(st):
	

Solutions:
def swap(st):
	tr = str.maketrans('aeiou', 'AEIOU')
	return st.translate(tr)


def swap(st):
	return ''.join((c.upper() if c in 'aeiou' else c for c in st))


def swap(string_):
	return string_.translate(str.maketrans('aeiou', 'AEIOU'))


import re

def swap(st):
	return re.sub('[aeiou]', lambda m: m.group(0).upper(), st)


def swap(st):
	translation = st.maketrans('aeiou', 'AEIOU')
	return st.translate(translation)


swap = lambda s: s.translate(s.maketrans('aiueo', 'AIUEO'))


def swap(st):
	for vowel in st:
		if vowel in ('a', 'e', 'i', 'o', 'u'):
			st = st.replace(vowel, vowel.upper())
	return st


def swap(stg):
	return ''.join((char.upper() if char in 'aeiou' else char for char in stg))


def swap(s):
	return s.translate(s.maketrans('aeiou', 'AEIOU'))