Path: csiph.com!eternal-september.org!reader02.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 18 May 2021 09:00:16 -0500 Newsgroups: fr.comp.lang.python Subject: Création d'une boucle qui sépare en fichiers à la rencontré du mot chapitre X-poster: PEAR::Net_NNTP v1.5.0 (stable) From: JiminyCricket Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Organization: !No_Organization! Message-ID: Date: Tue, 18 May 2021 09:00:16 -0500 Lines: 16 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-WMrQYVq7v+a6HCWjWmbk+mWZoGfjvqKQFC9JV/7af9EbRJaZD5qRCg6QlKUDeZLQxDiLxhyK2eVMQ+G!u/yqIuhsSSIF9/q8sdglrsxpQIzis7rVss921HRgN974/XX5z0w/hh9SxEGSxOm1aOnF537wXp4F X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Lines: 13 X-Original-Bytes: 1662 Xref: csiph.com fr.comp.lang.python:3529 Bonjour à tous, Je souhaiterais faire une boucle qui créé un nouveau fichier quand elle rencontre les mots 'chapitre' et 'épilogue'. Cela me ferait en tout 136 chapitres nommés chapitre_1.txt [...] épilogue. txt J'ai essayé la boucle For i in ligne: if 'CHAPTER' : print('chapitre_. txt') elif 'Epilogue' print('épilogue. txt') mais le terminal me donne le texte entier et 135 lignes chapitre_. txt sans pour autant me créer de nouveaux fichiers et l'épilogue n'apparaît pas. Je suis perdue. Est-ce que quelqu'un pourrait m'aider s'il vous plaît ? Merci d'avance pour vos réponses