Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20468 > unrolled thread

writing to a file from within nested loops

Started byRituparna Sengupta <rsengupta@wisc.edu>
First post2012-02-15 14:12 -0600
Last post2012-02-15 14:12 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  writing to a file from within nested loops Rituparna Sengupta <rsengupta@wisc.edu> - 2012-02-15 14:12 -0600

#20468 — writing to a file from within nested loops

FromRituparna Sengupta <rsengupta@wisc.edu>
Date2012-02-15 14:12 -0600
Subjectwriting to a file from within nested loops
Message-ID<mailman.5849.1329336768.27778.python-list@python.org>
Hi,

I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance.

Ritu



.
.
.
i=0
 while i<m
 r=name[i]
 f=open('file'+'%s' %(r), "a")
 f.write("whatever"+r)    #part outside innermost loop gets printed
 j=0
  while j<n
  f.write("output of loop")  #part within innermost loop doesn't get printed
  j=j+1
 f.close()
 i=i+1





[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web