nang-dev/English_To_pigLatin_Translator

Quick changes

Opened this issue · 0 comments

I took a look at the code, and made some quick changes. First, I noticed that you used the raw_input() function, which is a legacy Python 2.x.x feature, so I changed it to the new input() function for Python 3.x.x. Next, I simplified the vowel checker using the in() feature (Original wasn't bad, just super clunky). I also made some new variable names and put in some comments for readability. It works the same, just some quick quality of life changes


# Get user input
original = input('Enter a word: ')

# Check if the input is a valid word
if len(original) > 0 and original.isalpha():
    first_letter = original[0].lower()
    original_word = original.lower()

    # Translate the word to Pig Latin
    if first_letter in "aeiou":
        translated_word = original_word + pyg
    else:
        translated_word = original_word[1:] + first_letter + pyg

    # Print the translated word
    print(translated_word)
else:
    print('Error. Try again.')