def count(f_in, f_out):
f = open(f_in, "r")
m = open(f_out, "w")
for line in f:
o = line.find("|")
b = line.find("/")
p = len(line[:o])
q = len(line[b:])
m.write(str(p) + "\n") or (str(q) + "\n")
f.close()
m.close()
print(count("ippr.txt", "outp5.txt"))
I need to count the character before this sign(|) and after this sign (/) in this text(“ippr.txt”):
Mmmm mm | ppp ppppp pppp
Ll lllll/ddd dddd ddd dddd
Bbbbb bbb bbbb|yyyyy yyy yyy yyyyyyyy
It should print 10 / 17 / 14 (on three different lines), but I get 10 / 26 / 14