the script runs fine, but only records the last result in the .txt file. What am i doing wrong?
a= float(input('Insert a: '))
b= float(input('Insert b: '))
for c in range(10,300):
d= float(46+(9*a)-(7*c))
e= float(-6+(463*b)+(-1*c)+(0.8*a)+(0.89*d))
print(d)
print(e)
import sys
sys.stdout=open("loop.txt","w")
print(d)
print(e)
sys.stdout.close()
You can write these values inside the loop itself
a= float(input('Insert a: '))
b= float(input('Insert b: '))
with open("loop.txt","w") as f_out:
for c in range(10,300):
d= float(46+(9*a)-(7*c))
e= float(-6+(463*b)+(-1*c)+(0.8*a)+(0.89*d))
f_out.write('{} {}\n'.format(d, e))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments