I am currently working on my Pig Latin code in python. I am encountering two errors, the first one is dealing with consonants. If a word begins with two consonants, both letters are moved to the end and 'ay' is appended: grade becomes to adegray for instance.
My second issue is, that I get invalid syntax error, when I try to run my code below:
#Pig latin
pig= ("ay")
word = input("Enter a word: ")# prompt for a phrase and assign result to a variable
vowels="aeiou" # list of vowels
words = word.split()
# for word in words
for i in range(len(word)):# assign first letter of phrase to a string variable, for later use
if word[i][0] in vowels: # is first letter a vowel
print(word[i] + 'way') # if first letter is a vowel, print word + 'way'
elif word[i][1] in vowels:
print(word[i][1:]+word[i][0] + 'ay' # assign second letter of phrase to a string variable, for later use
else:
print(word[i]+ [1:]=('ay') # otherwise print word with first two letters moved to end & added 'ay'