sentence = input("Say a sentence: ").split()
vowels = 'aeiouAEIOU'
for i in sentence:
if i.isalpha() == True:
if i[0] in vowels:
print(i + "way")
new = i + "way"
sentence.replace(i, new)
else:
print(i[1:] + i[0] + "ay")
new = i[1:] + i[0] + "ay"
sentence.replace(i, new)
else:
print(i)
print(sentence)
I am trying to make a piglatin sentence converter, I have been able to make the converter print the correct values for the translation, but I cannot make the program change the actual values of the list, which I need it to do so that I can print the converted text like the original, in a string format like "I like rabbits" instead of a list like:
- I
- like
- rabbits
I would like to know how I use the replace() function to change my list inside my for loop and if statements. If there is another way that is better that would be even better. Thank You.