title: How to make Python check if ftp directory exists?
body: <p>I'm using this script to connect to sample ftp server and list available directories:</p>
  
  <pre><code>from ftplib import FTP
  ftp = FTP('ftp.cwi.nl')   # connect to host, default port (some example server, i'll use other one)
  ftp.login()               # user anonymous, passwd anonymous@
  ftp.retrlines('LIST')     # list directory contents
  ftp.quit()
  </code></pre>
  
  <p>How do I use ftp.retrlines('LIST') output to check if directory (for example public_html) exists, if it exists cd to it and then execute some other code and exit; if not execute code right away and exit?</p>