Spaces:
Sleeping
Sleeping
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)}" |