Dec-31-2016, 07:19 PM
I need the
I have tried taking the
lines()
function to write the results of a = [int(x) for x in str(i)]
to fibo.txt but it's coming up empty.I have tried taking the
f.write()
out of the for loop but it has the same results. Do I need a separate function for f.write()
? def F(): a, b = 0, 1 yield a yield b while True: a, b = b, a + b yield b def subfib(StartNumber, endNumber): for cur in F(): if cur > endNumber: return if cur >= StartNumber: yield cur def lines(): for i in subfib(2, 400): a = [int(x) for x in str(i)] with open('fibo.txt', 'w') as f: f.write(a) f.close() lines()