Quick Easy Question

Hello I’m currently learning python. I was given this project to do.
The goal of the program is to take an input and print the input but with every vowel replaced by the letter “g”.
dog → dgg
Can someone tell me:
Why it only checks the “if” statement once?
Why it only checked the first variable “a”?
Why my code isn’t running the “else” section of it?

The problem is that or doesn’t do what you’re using it for here. It’s for combining multiple comparison results, what your if statement is checking is either if char != "a" is true, or "e" is true, or "i" is true, etc. For strings any non-empty string is true, so it’ll always succeed. What you actually want to do is either of these:

if char != "a" and char != "e" and char != "i" and char != "o" and char != "u":
if char not in ["a", "e", "i", "o", "u"]:

You actually want and, since the character is a non-vowel only if it doesn’t match all the vowels. in is even better - it checks if a value is or isn’t present in something you can loop over.

Thank You, I appreciate it.
Do you know why “Hello” isnt converting using my program?
“and char” causes an error with the quotations.

I was showing two ways you could write the if statement that works, just use one on its own.

Great Thanks.