How to Overwite a line in file using python?
this is my list in text file
"Sample" , "S"
"Simple" , "T"
"test" , "S"
how to Overwite the second line?
"Simple", "T"
into
"Simple", "S"
then the text file will be change like this:
"Sample" , "S"
"Simple" , "S"
"test" , "S"
Here is my code i use function for the flow
list = []
#put your sample csv file here
fileName = 'list.txt'
#reading file text
def openFile(filename):
content = open(filename)
lines = content.readlines()
for line in lines:
list.append(line)
return content
def mark(fileName):
flag = open(pick, "w")
choice = input("Enter number to mark: ")
for choice in list:
flag.write(choice[1].replace('"T"', '"S"')
AnyOne can help me to solve this hard problem??