I am writing a script that will replace the word in the file with a user input. Script:
print "enter your text" newText = input("#") with open('test.txt', 'r') as f: old_data = f.read() new_data = old_data.replace('oldtext', (newText)) with open('test.txt', 'w') as f: f.write(new_data) What's my mistake?
new_data = old_data.replace('oldtext', newText)- Alexshev92newText = raw_input("#"). In python2inputiseval(raw_input(prompt)), so the result will be interpreted depending on the input, and innewTextshould be a line - gil9red