Skip to content

Instantly share code, notes, and snippets.

@victormurcia
Created September 5, 2022 05:06
Show Gist options
  • Select an option

  • Save victormurcia/249f2941fbc7d3ade7db5dfe31d3f8c5 to your computer and use it in GitHub Desktop.

Select an option

Save victormurcia/249f2941fbc7d3ade7db5dfe31d3f8c5 to your computer and use it in GitHub Desktop.
list chapters in book
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