Question: I am attempting to write a code for class and was having trouble with the end and ran across this as a solution: for
I am attempting to write a code for class and was having trouble with the end and ran across this as a solution:
for file in os.listdir(cats_path):
print('{0} : {1} bytes'.format(file, os.path.getsize(cats_path / file)))
I am trying to list to contents of a folder in bytes. When attempting this code, I am getting this error:
line 24, in
print('{0} : {1} bytes'.format(file, os.path.getsize(cats / file)))
TypeError: unsupported operand type(s) for /: 'str' and 'str'
Can you tell what I am doing wrong?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
