[Tutor] commands

Shurui Liu (Aaron Liu) shurui91 at gmail.com
Mon Mar 29 02:38:22 CEST 2010


# Translate wrong British words

#Create an empty file
print "\nReading characters from the file."
raw_input("Press enter then we can move on:")
text_file = open("storyBrit.txt", "r+")
whole_thing = text_file.read()
print whole_thing
raw_input("Press enter then we can move on:")
print "\nWe are gonna find out the wrong British words."
corrections = {'colour':'color', 'analyse':'analyze',
'memorise':'memorize', 'centre':'center', 'recognise':'recognize',
'honour':'honor'}
texto = whole_thing
for a in corrections:
    texto = texto.replace(a, corrections[a])
print texto

# Press enter and change the wrong words
if "colour" in whole_thing:
    print "The wrong word is 'colour' and the right word is 'color'"
if "analyse" in whole_thing:
    print "the wrong word is 'analyse' and the right word is 'analyze'"
if "memorise" in whole_thing:
    print "the wrong word is 'memorise' and the right word is 'memorize'"
if "centre" in whole_thing:
    print "the wrong word is 'centre' and the right word is 'center'"
if "recognise" in whole_thing:
    print "the wrong word is 'recognise' and the right word is 'recognize'"
if "honour" in whole_thing:
    print "the wrong word is 'honour' and the right word is 'honor'"

# We are gonna save the right answer to storyAmer.txt
w = open('storyAmer.txt', 'w')
w.write('I am really glad that I took CSET 1100.')
w.write('\n')
w.write('We get to analyse all sorts of real-world problems.\n')
w.write('\n')
w.write('We also have to memorize some programming language syntax.')
w.write('\n')
w.write('But, the center of our focus is game programming and it is fun.')
w.write('\n')
w.write('Our instructor adds color to his lectures that make them interesting.')
w.write('\n')
w.write('It is an honor to be part of this class!')
w = open("assign19/storyAmer.txt", "w")

w.close()



This is what I have done, I don't understand why this program cannot
fix "analyse".

-- 
Shurui Liu (Aaron Liu)
Computer Science & Engineering Technology
University of Toledo


More information about the Tutor mailing list