To list all the files in the current directory in Python, you can use the os
module.
main.py68 chars7 lines
The os.listdir()
function returns a list of all the files and directories in the current working directory.
In the loop, we simply print each file name one by one. This code should work to list all the files in the current directory.
gistlibby LogSnag