I have to make a program that takes the list of files from a directory and save them in an array to see if they are files or folders. I have the following code:
#!/usr/bin/python
import subprocess, os
array = subprocess.check_output(["ls","-a","/usr/bin/"])
for h in array:
if os.path.isdir(h):
print 'bandera1'
else:
print 'bandera2'
but at the time of doing that, it takes character by character of the variablle array, how could I take the complete word corresponding to the file name?