Skip to content

Commit

Permalink
Merge pull request #48 from geeksambhu/patch-1
Browse files Browse the repository at this point in the history
Formatted code
  • Loading branch information
shabda committed Aug 8, 2018
2 parents 5569728 + 86c61f3 commit 9bd050e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ascii-art.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ Prints alternating patterns in # and * based on a given integer n. n=7 here.
Display current directory as a tree
=======================================

import os
.. code-block:: python
import os
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
def list_files(startpath):
for root, dirs, files in os.walk(startpath):
level = root.replace(startpath, '').count(os.sep)
indent = ' ' * 4 * (level)
print('{}{}/'.format(indent, os.path.basename(root)))
Similar to running tree

Expand Down

0 comments on commit 9bd050e

Please sign in to comment.