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()
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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() |