have to write in python 2 txt.files one is input of numbers: writen in 2 lines 4-1 and 12-3 I have to make the subtraction and write the result to other txt.file
please help me I am very green to python, just started to learn it. Thanks you all in advance
this is what I managed to write till now:
import calculator
with open ('./expresii.txt', 'r') as f:
line = f.readlines()
for l in line:
if l[1] == '-':
print(calculator.subtraction(int(l[0]), int(l[2])))
else:
print(calculator.addition(int(l[0]), int(l[2])))
with open ('./expresii.txt', 'r') as f2:
print(f2.read())
in first I get the subtraction of numbers and from the second I get the numbers that must be subtrated
now how do I write toa new file 4-1=3 and 12-3=9 this must be the result