Feb-28-2021, 01:40 PM
hello, I have to make a kind of interpreter to read books of choice.
But we are blocking on the addition of the text with the chapters to have a great syntax.
But we are blocking on the addition of the text with the chapters to have a great syntax.
def livre(nom) : with open (nom,"r",encoding="utf8") as fichier : contenu = fichier.read() texte1 = contenu.split('\n') doc = [['préliminaire','']] suite = [] for ligne in texte1 : ok=ligne.find("*") if ok == 0 : doc.append([ligne[1:].strip(),"" ]) else: suite.append([ligne[0:]]) print (doc)
Output:[['préliminaire', ''], ['Chapitre 1', ''], ['Chapitre 2', ''], ['Chapitre 3', ''], ['Chapitre 4', ''], ['Chapitre 5', '']]
Thanks for your help.