"pig latin" tells me i'm wrong but the interpreter says otherwise

Hi, first off all, thank you for making this website, you’re amazing, but i think there is and issue with the “pig latin” exercise in python where my interpreter gave a different answer than the tester with this code:
PS: yes the code is awful, it’s a draft, that’s not what matters.

VOWELS = {"a", "e", "i", "o","u","A", "E", "I", "O", "U"}

def translate(text):
    consontant = ""
    
    if text[:2] == "xr" or text[:2] == "yt":
        return text + "ay"
        
    for letter in text:
        if is_consonant(letter):
            if letter != "y":
                VOWELS.add("y")
            if text[:2] == "qu":
                consontant += text[:2]
                text = text.replace(text[:2],"",1)
                break
            else:
                consontant += letter
                text = text.replace(text[0],"",1)
        else:
            break
    return str(text + consontant + "ay")

def is_consonant(letter):
    return not any (i in VOWELS for i in letter)
    
print(translate("yellow"))

here, the print (and ourselves if we look into it) says that the final print will be “ellowyay”, but pytest will tell you that it gives “yelloway”

obligatory “english is not my first language”

Try changing that print line to this:

for word in ["yellow", "bob", "yellow"]:
    print(word, "-->", translate(word))

When I run that, I get:

» python pig_latin.py
yellow --> ellowyay
bob --> obbay
yellow --> yelloway

Does that help? :slight_smile:

aaaaand you made me realize that the problem has nothing to do with unit test, but just my code that modify the VOWELS constants, which sabotages the rest of the unit test, my bad.

Precisely ;) Well solved!