<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_and_upload_images(client, image_type, language, base_dir):
 """ Delete and upload images with given image_type and language. Function will stage delete and stage upload all found images in matching folders. """

    print('{0} {1}'.format(image_type, language))
    files_in_dir = os.listdir(os.path.join(base_dir, language))
    delete_result = client.deleteall(
        'images', imageType=image_type, language=language)

    deleted = delete_result.get('deleted', list())
    for deleted_files in deleted:
        print('  delete image: {0}'.format(deleted_files['id']))

    for image_file in files_in_dir[:8]:
        image_file_path = os.path.join(base_dir, language, image_file)
        image_response = client.upload(
            'images',
            imageType=image_type,
            language=language,
            media_body=image_file_path)
        print("  upload image {0} new id {1}".format(image_file, image_response['image']['id']))