Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- textlist = ["Acts 1.txt", "1 Chronicles 1.txt", "2 Samuel 15.txt"]
- for text in textlist:
- text = text.replace('.', ' ')
- mylist = text.split(' ')
- if mylist[-1] == "txt":
- mylist.pop(-1)
- res = ""
- digitctr = 0
- for s in mylist:
- if s.isdigit(): # process a digit group
- if res:
- digitctr += 1
- if digitctr == 1: # 1st digit group after title is chapter
- res += " Chapter "
- elif digitctr == 2: # 2nd digit group after title
- res += " Paragraph " # ?????????
- res += num2words(int(s))
- res += " "
- else: # a non-digit group
- res += s
- print(res)
- # output:-
- # Acts Chapter One
- # One Chronicles Chapter One
- # Two Samuel Chapter Fifteen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement