You can download this code by clicking the button below.
This code is now available for download.
This function compresses two files into a single zip file.
Technology Stack : os, zipfile
Code Type : File operation
Code Difficulty : Intermediate
def zip_file(file1, file2):
"""
Compress two files into a single zip file.
"""
import os
import zipfile
with zipfile.ZipFile('combined.zip', 'w') as zipf:
zipf.write(file1)
zipf.write(file2)