# Reading line of text
text = input("Enter text: ")
print("English: " ,text)
# Removing punctuation
text = removePunctuation(text)
# Converting to lower case
text = text.lower()
# Iterating over words
for word in text.split(" "):
# Converting word to Pig Latin form
word = pigLatin(word)
# Printing word
print(word, end = " ");
我该如何说Pig:
,然后说拉丁语形式?每次尝试此操作时,它都会将猪拉丁转换添加到上一个单词中。
您正在尝试使一个变量一次做两件事。如果您以后要使用旧值(在印刷中),请退出销毁原始值:
pl_word = pigLatin(word)
print (word, pl_word)
print("Pig:", word)
下次,请使用大写字母和一些降价... https://stackoverflow.com/editing-help