:
for word in string.split(' '):
if word in textDict:
translatestring = translatestring + textDict[word]
else:
translatestring = translatestring + word
string.split(''): translateetring + = textDict.get(, )
dict.get(foo, default) foo default, foo .
(Start time, short notes now: when splitting, you can split based on punctuation as well as spaces, save punctuation or spaces and re-enter it when connected to the output line. This is a bit more work, but it will do the job.)
source
share