Deutsch English Français Italiano |
<relier-20241202121602@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: fr.comp.lang.python Subject: Re: =?UTF-8?Q?Panne_de_m=C3=A9moire_avec_list_et_str?= Date: 2 Dec 2024 11:17:34 GMT Organization: Stefan Ram Lines: 34 Expires: 1 Jan 2026 11:59:58 GMT Message-ID: <relier-20241202121602@ram.dialup.fu-berlin.de> References: <vik35m$393an$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de /8U1o0py6t7T127iiyekQQt3bHDRuE5C2TIM5z+9XC6Jlk Cancel-Lock: sha1:J2oz8C7HzbThUVQKRQVS9wg+KQk= sha256:bP/6O6TWluGxtWa21P8NL9QAciOEGCJGQXU8dsSnDks= X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: fr Bytes: 2295 Dominique <dominique.sextant@orange.fr.invalid> a écrit ou cité : >Là, j'ai honte, j'en conviens bien, mais ça fait 1 heure que je cherche >sans trouver. >Soit une liste qui se présente comme suit : >[['2'], ['2'], ['6'], ['8'], ['9']] >Comment l'obtenir sous la forme '22689' ? >Merci et belle journée à tous, Moi aussi, je souhaite une bonne journée à tout le monde ! Dans un tel cas, je dresserais la liste des démarches nécessaires : - convertir chacune des listes internes en la chaîne de caractères qu'elle contient - relier ces chaînes. def convertir( l ): for e in l: yield e[ 0 ] def relier( l ): return ''.join( l ) l = [ [ '2' ],[ '2' ],[ '6' ],[ '8' ],[ '9' ]] print( relier( item for item in convertir( l ))) ou, en raccourci : l = [ [ '2' ],[ '2' ],[ '6' ],[ '8' ],[ '9' ]] print( ''.join( e[ 0 ]for e in l ))