Right now I'm trying to create an oppish translator. That is, after a consonant or several consonants in a row, you add 'op' to those letters. As an example, cow would become copowop or street which would become stropeetop. This is what I have so far:
def oppish(phrase): #with this function I'm going to append 'op' or 'Op' to a string.
consonants = ['b','c','d','f','g','h','i','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
vowels = ['a', 'e', 'i', 'o', 'u'] #this and the preceding line create a variable for the vowels we will be looking to append 'op' to.
if phrase == '': #error case. if the input is nothing then the program will return False.
return False
phrase_List = list(' ' + phrase) # turns the input phrase into a list which allows for an index to search for consonants later on.
new_phrase_List = list() #creates new list for oppish translation
for i in range(1, len(phrase_List)):
if phrase_List[i] == phrase_List[1]:
new_phrase_List.append(phrase_List[i])
elif phrase_List[i] in consonants:
new_phrase_List.append('op') #adds op to the end of a consonant within the list and then appends it to the newlist
new_phrase_List.append(phrase_List[i]) #if the indexed letter is not a consonant it is appended to the new_phrase_list.
print 'Translation: ' + ''.join(new_phrase_List)
oppish('street')
The only problem here is that the above code yields this
Translation: ssoptopreeopt
I'm not sure what I've done wrong, I've tried going through a visualizer but to no avail. All help is appreciated! :)