0

I tried to add a condition to where if the while loop meets a "Y" or "y" it will still move the letters to the end, but keep "Y" or "y" at the beginning, yet the loop will end and just add "ay"

print("Pig Latin Translator Test!")
name = raw_input("What is your name, friend?")
if len(name) > 0 and name.isalpha():
    print("Hello!")
else:
    print("That's not a name!")
word = raw_input("What is your word?")
VOWELS = ("a", "e", "i", "o", "u", "A", "E", "I", "O", "U")
YList = ("Y", "y")
if word[0] in VOWELS:
    word = word + "yay"
else:

This is the section causing problems:

    while word[0] in YList or (not VOWELS):
        word = word[1:] + word[0]
    word = word + "ay"
print (word)
4
  • possible duplicate of python pig latin converter Commented Jul 2, 2015 at 7:29
  • Why do you use both capital and lowercase characters for the vowels instead of using the .upper() and .lower() functions? Commented Jul 2, 2015 at 11:53
  • It is a pig latin converter;However, it is not a duplicate of that code. Commented Jul 2, 2015 at 19:49
  • And I didn't think of calling on those functions actually Commented Jul 2, 2015 at 19:49

1 Answer 1

1

The value of (not VOWELS) is always falsy because VOWELS is truthy.

You meant to write:

while word[0] in YList or (word[0] not in VOWELS):
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.