Hello, i have proplem with the following excercise:
There's a txt file which contains tab seperated words like:
Name N1 N2 Type
FFapple 11 15 fruit
ZZbanana 33 45 fruit
ZZcarrot 22 25 vegetable
FFapricot 10 30 fruit
ZZmelon 22 50 fruit
FFbroccoli 16 40 vegetable
i want to do the following things with it:
1. selecting the lines start with FF and write them out without FF into another txt file in a format like:
apple -- fruit -- 15
apricot -- fruit -- 30
broccoli -- vegetable -- 40
2. same as 1. but write the lines only where N2 is bigger than 25
apricot -- fruit -- 30
broccoli -- vegetable -- 40
but i stucked at the begining, i get syntax error for the first comma
def filter("list.txt", "new.txt"):
fs = open("list.txt", "r")
fd = open("new.txt", "r")
while 1:
txt = fs.readline()
if txt =="":
break
if txt[0] == "FF":
fd.write(txt)
fs.close()
fd.close()
return