Guest User

Untitled

a guest
Aug 14th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. For each member of a list, write it to a separate file, python
  2. for item in lst:
  3. for i in range(len(lst)):
  4. write_to_me = open('list_item_%i.txt' %i, 'w')
  5. write_to_me.write(item)
  6.  
  7. for i, item in enumerate(lst):
  8. write_to_me = open('list_item_{0}.txt'.format(i), 'w')
  9. write_to_me.write(item)
  10. write_to_me.close()
Add Comment
Please, Sign In to add comment