列表下面的程序的目的是单词4个字符转换从"This"
到"T***"
,我已经完成了艰难的部分获得该名单和len工作。把功能输出在Python
的问题是程序输出由行答案行了,我不知道是否有无论如何,我可以回到存储输出到一个列表,并把它打印出来作为一个完整的句子?
谢谢。
#Define function to translate imported list information
def translate(i):
if len(i) == 4: #Execute if the length of the text is 4
translate = i[0] + "***" #Return ***
return (translate)
else:
return (i) #Return original value
#User input sentense for translation
orgSent = input("Pleae enter a sentence:")
orgSent = orgSent.split (" ")
#Print lines
for i in orgSent:
print(translate(i))
串行downvoter,FY。 –