H
hokiegal99
I'm trying to count the number of files within a directory, but I
don't really understand how to go about it. This code:
for root, dirs, files in os.walk(path):
for fname in files:
x = str.count(fname)
print x
Produces this error:
TypeError: count() takes at least 1 argument (0 given)
for root, dirs, files in os.walk(path):
for fname in files:
x = list.count(files)
print x
TypeError: count() takes exactly one argument (0 given)
Also wondered why the inconsistency in error messages (numeric 1 vs.
one)??? Using 2.3.0
Thanks!!!
don't really understand how to go about it. This code:
for root, dirs, files in os.walk(path):
for fname in files:
x = str.count(fname)
print x
Produces this error:
TypeError: count() takes at least 1 argument (0 given)
for root, dirs, files in os.walk(path):
for fname in files:
x = list.count(files)
print x
TypeError: count() takes exactly one argument (0 given)
Also wondered why the inconsistency in error messages (numeric 1 vs.
one)??? Using 2.3.0
Thanks!!!