a = "alchemist"
b = "berry picker"
c = "camera assistant"
# this continues for all letters of the alphabet, with each string beginning with its corresponding variable name.
character = (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
def indefinite_article():
for index in character:
if index in ("a", "e", "i", "o", "u"):
return("An ")
else:
return("A ")
What I would like to happen: if a letter from character is a vowel, the string "An " will print. If a letter from character is a consonant, the string "A " will print.
I have tested several versions of the indefinite_article() function, including:
if index in (a, e, i, o, u) This always prints "An ".
if index in ("a", "e", "i", "o", "u") This always prints "A ".
if index[0] in (a, e, i, o, u) This always prints "A ".
if index[0] in ("a", "e", "i", "o", "u") This always prints "An ".
Why is this the case, and how can I fix it?