>>> from inventari import valor_total >>> round(valor_total('inventari.txt'),2) 15897.13 >>> s = '004512 95 4.80\n009873 12 220.50\n187632 310 3.99\n76543 58 2.10\n9021 440 1.85\n33456 27 67.25\n776521 150 9.30\n55210 6 15.00\n120034 82 18.45\n' >>> with open ('inventari2.txt','w') as f: ... n = f.write(s) >>> round(valor_total('inventari2.txt'),2) 10088.35