python count files in directory with extension code example Example: python count files directory import os len(os.listdir(directory))