title: How to clear output in jupyter notebook cell after each for loop?
body: <p>So, for each for loop, I generate an image + ask the user to input 'yes' or 'no'. I'd like the image &amp; the user input line to be cleared from the cell before I generate a new image &amp; new user input line. Instead, only the image is being cleared/replaced (the user input line doesn't show at all).<br />
  This is what it looks like now (everything under for loop should be indented to right):
  <a href="https://i.stack.imgur.com/vF01Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vF01Y.png" alt="enter image description here" /></a></p>
  <pre><code>for filename in os.listdir(folder):
  clear_output(wait=True)
  split_filename=os.path.splitext(filename)[0] #splitting filename from .jpg
  image_id, age=split_filename.split('_', 2) #saving image_id and age
  #print([image_id, age])
  
  if int(image_id)&gt;= starting_image_id: #start at a certain image #, specified above    
      image_ids.append(image_id) 
      ages.append(age)
   
      #This line below displays image in original color:
      #display.display(Image.open(os.path.join(folder,filename)))
      
      #These 5 lines below display image in grayscale:
      image = cv2.imread(os.path.join(folder,filename))
      image1 = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
      plt.figure()   # create a new figure
      plt.imshow(image1, cmap='gray')
      plt.show()
                       
      attractive_rating=0 #so that while loop will run until user input = y or n 
      while attractive_rating != 'y' and attractive_rating !='n':
          attractive_rating=input('Do you find this face attractive? Enter y/n:')
      attractive_labels.append(attractive_rating) 
      
      if attractive_labels.count('y') &gt; 2 and attractive_labels.count('n')&gt;2:
          break 
  </code></pre>