Expanded Translator for multiple consonants/vowels etc, Please critique


#1

Hello,

I wanted to make a translator that works with words that start with 1/2/3/4 vowels or words that start with 1/2/3/4 consonants, words that use y as a vowel or a consonant. Like style, schlep, chrysolite, phyryganeides, boots, and the like.

It's a lot of code but could you test it to see if there are any errors. I tried to cover all my bases but im sure I missed something.

Thank you for your time.

cpyg = "ay"
vpyg = "way"
vowels = "aeiou"
cons = "bcdfghjklmnpqrstvwxyz"

original = raw_input("Enter a word:")

if original[0] in vowels:
new_word = original + vpyg
print new_word

elif original[0] != "y":
vowels = "aeiouy"
cons = "bcdfghjklmnpqrstvwxz"
if original[0] in cons and original[1] in cons and original[2] in cons and original[3] in cons:
start = original[0:4]
new_word = original[4:len(original)] + start + cpyg
print new_word
elif original[0] in cons and original[1] in cons and original[2] in cons:
start = original[0:3]
new_word = original[3:len(original)] + start + cpyg
print new_word
elif original[0] in cons and original[1] in cons:
start = original[0:2]
new_word = original[2:len(original)] + start + cpyg
print new_word
elif original[0] in cons:
if original[0] == "q" and original[1] == "u":
start = original[0:2]
new_word = original[2:len(original)] + start + cpyg
print new_word
else:
start = original[0:1]
new_word = original[1:len(original)] + start + cpyg
print new_word
else:
start = original[0:1]
new_word = original[1:len(original)] + start + cpyg
print new_word

elif original[0] in cons and original[1] in cons and original[2] and original[3] in cons:
start = original[0:4]
new_word = original[4:len(original)] + start + cpyg
print new_word

elif original[0] in cons and original[1] in cons and original[2] in cons:
start = original[0:3]
new_word = original[3:len(original)] + start + cpyg
print new_word

elif original[0] in cons and original[1] in cons:
start = original[0:2]
new_word = original[2:len(original)] + start + cpyg
print new_word

elif original[0] in cons:
if original[0] == "q" and original[1] == "u":
start = original[0:2]
new_word = original[2:len(original)] + start + cpyg
print new_word
else:
start = original[0:1]
new_word = original[1:len(original)] + start + cpyg
print new_word

else:
print "Please enter a valid word."


#2

There were a couple of invalid syntax errors and indentations needed when I checked.


#3

Really? Perhaps it was a copy and paste issue as it runs ok on mine. The formatting does seem off in the post though but I don't know how to fix it there.


#4

You can use command shift c on a mac or the 6th to the right symbol in the spacebar to paste your code.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.