I was researching on ftplib, I implemented for what I needed but their is no straight command or function like direxist() of os module, however one guy named Tom has made it, its pretty simple and works...
Next I declared a variable num and set it to 0.
then comes the for loop that I used to loop and check the directory to be uploaded to exist or not. If the directory specified in uploadToDir exist we perform the operation we want and set the value of num to 1 , now since the value is changed to 1 which means the directory exist or else if it doesn't the num evaluates to 0 that prints the message directory not found or in this case, Public_html not found.
source: stackoverflow