Login and get codingComplete
count_dirs_and_files
traversing the passed indirectory
path.Return a tuple of (number_of_directories, number_of_files)
Let's use the
tree
command to show an example:$ mkdir -p project/a/1/I project/a/1/II project/a/2 project/b/1/I tree project/ project/ ├── a │ ├── 1 │ │ ├── I │ │ └── II │ └── 2 └── b └── 1 └── I 8 directories, 0 filesYour solution should match these counts:
$ python >>> from tree import count_dirs_and_files >>> count_dirs_and_files('project') (8, 0)Let's add two files:
$ touch project/a/1/I/bob $ touch project/a/2/julian $ python >>> from tree import count_dirs_and_files >>> count_dirs_and_files('project') (8, 2)Good luck and have fun!
286 out of 286 users completed this Bite.
Will you be Pythonista #287 to crack this Bite?
Resolution time: ~43 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 3.67 on a 1-10 difficulty scale.
» You can do it! 😌