import os def list_files_in_directory(): # Prompt the user for the directory path directory = input("Please enter the directory path: ") # Check if the provided path is a valid directory if not os.path.isdir(directory): print(f"The path {directory} is not a valid directory.") return # List all files in the directory try: files = os.listdir(directory) print(f"\nFiles in directory '{directory}':") for file in files: print(file) except Exception as e: print(f"An error occurred: {e}") # Run the function list_files_in_directory()