File size: 459 Bytes
7cfcffc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os

def format_directory(directory):
    """Formats the contents of a directory for display."""
    try:
        # List all files in the directory
        files = os.listdir(directory)
        if not files:
            return "No files found."
        
        # Create a formatted string of files
        formatted_files = "\n".join(files)
        return formatted_files
    except Exception as e:
        return f"Error accessing directory: {str(e)}"