I am learning python and I am trying to write a code that allows me to read in a file, then change a portion of each line in a text file, and the output is written to the file.
Each line in the file has different years and information in it.
What I have so far is:
filein = input('file.txt', 'r')
for line in filein:
str = "1984 - 2000"
print str.replace("1984 - 2000", "1970 - 2010")
file.close()
When I try this I get this error "SyntaxError: multiple statements found while compiling a single statement"
How can I fix/ improve this code?
file? You must define it.