Created
September 5, 2022 05:06
-
-
Save victormurcia/249f2941fbc7d3ade7db5dfe31d3f8c5 to your computer and use it in GitHub Desktop.
list chapters in book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| chapter_list = [] | |
| for file in os.listdir("."): | |
| if file.endswith(".txt"): | |
| chapter_list.append(file) | |
| #Do a natural sort on the texts files | |
| chapter_list.sort(key=lambda x: '{0:0>8}'.format(x).lower()) | |
| chapter_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment