Vowel or consonant

Assume the input is exactly one English lowercase letter from a to z.

Write a function that takes a single character (a lowercase letter) as input and returns “Vowel” if it’s a vowel, namely, “a”, “e”, “i”, “o”, or “u”, or “Consonant” otherwise. Use only if statements.

Complete Listing 1. Save the completed code as is_vowel_or_consonant.py and run it to check the supplied assertions.

Listing 1: Starter function and checks for is_vowel_or_consonant.
def is_vowel_or_consonant(char: str) -> str:
    raise NotImplementedError("Replace this line with your code.")


# The first vowel
got = is_vowel_or_consonant("a")
assert got == "Vowel", f"'a': expected 'Vowel', got {got!r}"

# A vowel in the middle of the list
got = is_vowel_or_consonant("i")
assert got == "Vowel", f"'i': expected 'Vowel', got {got!r}"

# The last vowel, missed by a check that stops early
got = is_vowel_or_consonant("u")
assert got == "Vowel", f"'u': expected 'Vowel', got {got!r}"

# A consonant next to a vowel in the alphabet
got = is_vowel_or_consonant("b")
assert got == "Consonant", f"'b': expected 'Consonant', got {got!r}"

# The last letter of the alphabet
got = is_vowel_or_consonant("z")
assert got == "Consonant", f"'z': expected 'Consonant', got {got!r}"

# Your case: which letter is most likely to break it?
# got = is_vowel_or_consonant("___")
# assert got == "___", f"'___': expected '___', got {got!r}"
  • assert condition checks a Boolean condition. A true condition produces no output; a false condition raises AssertionError. For example, assert 2 + 3 == 5 passes.