python - Program to write all the numbers divisible by 99 to a text file not working? -


i trying write simple program starts @ number 99 , writes down multiples of 99 under 1000000000 text file named: 'blank.txt' code:

f = open('blank.txt') = 99 while <= 1000000000:    f.read()    = str(a)    f.write(a)    = int(a)    = * 2  f.close() 

one problem.. reason can't write text file? please me able write multiples of 99 text file. btw if have way using python please post it!

you need open file in write('w') mode:

with open('blank.txt', 'w') f:    num in range(99, 1000000001, 99):        #do here. 

note there's no need close file now, with statement automatically you.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -