SyntaxFix
Write A Post
Hire A Developer
Questions
def replace_line(file_name, line_num, text): lines = open(file_name, 'r').readlines() lines[line_num] = text out = open(file_name, 'w') out.writelines(lines) out.close()
And then:
replace_line('stats.txt', 0, 'Mage')