title: IsADirectoryError: [Errno 21] Is a directory ERROR when trying to copy images into another file
body: <p>I'm trying to copy 90% of images of a source file into a training folder but I have the following error:</p>
  <pre><code>IsADirectoryError                         Traceback (most recent call last)
  &lt;ipython-input-24-e1fe9ed34fea&gt; in &lt;module&gt;
       50 
       51 split_size = .9
  ---&gt; 52 split_data(CAT_SOURCE_DIR, TRAINING_CATS_DIR, TESTING_CATS_DIR, split_size)
       53 split_data(DOG_SOURCE_DIR, TRAINING_DOGS_DIR, TESTING_DOGS_DIR, split_size)
  
  &lt;ipython-input-24-e1fe9ed34fea&gt; in split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE)
       33     for i in training_set:
       34         if os.path.getsize(SOURCE + i) != 0:
  ---&gt; 35             copyfile(SOURCE+i, TRAINING)
       36 
       37     for j in testing_set:
  
  /usr/lib/python3.6/shutil.py in copyfile(src, dst, follow_symlinks)
      119     else:
      120         with open(src, 'rb') as fsrc:
  --&gt; 121             with open(dst, 'wb') as fdst:
      122                 copyfileobj(fsrc, fdst)
      123     return dst
  
  IsADirectoryError: [Errno 21] Is a directory: '/tmp/cats-v-dogs/training/cats'
  </code></pre>
  <p>This is my code:</p>
  <pre><code>def split_data(SOURCE, TRAINING, TESTING, SPLIT_SIZE):
      list = os.listdir(SOURCE)
      
      images_list = random.sample(list, len(list))
      training_set = []
      testing_set = []
      split_len = int(SPLIT_SIZE*len(list))
      for image in range(len(list)):
          if image &gt;= split_len:
              testing_set.append(list[image])
          else:
              training_set.append(list[image])
          
      for i in training_set:
          if os.path.getsize(SOURCE + i) != 0:
              copyfile(SOURCE+i, TRAINING) 
      
      for j in testing_set:
          if os.path.getsize(SOURCE + j) != 0:
              copyfile(SOURCE+j, TESTING)
  
  
  CAT_SOURCE_DIR = &quot;/tmp/PetImages/Cat/&quot;
  TRAINING_CATS_DIR = &quot;/tmp/cats-v-dogs/training/cats&quot;
  TESTING_CATS_DIR = &quot;/tmp/cats-v-dogs/testing/cats&quot;
  DOG_SOURCE_DIR = &quot;/tmp/PetImages/Dog/&quot;
  TRAINING_DOGS_DIR = &quot;/tmp/cats-v-dogs/training/dogs&quot;
  TESTING_DOGS_DIR = &quot;/tmp/cats-v-dogs/testing/dogs&quot;
  
  split_size = .9
  split_data(CAT_SOURCE_DIR, TRAINING_CATS_DIR, TESTING_CATS_DIR, split_size)
  split_data(DOG_SOURCE_DIR, TRAINING_DOGS_DIR, TESTING_DOGS_DIR, split_size)
  </code></pre>
  <p>I think the error is in the function copyfile() but I was sure that I was putting the right paths as arguments, where <code>copyfile(SOURCE+i, TRAINING)</code> is supposed to copy the image in the source file to the training directory.
  I would appreciate any help!
  Thank you!</p>