Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3495
| Path | csiph.com!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!border2.nntp.ams1.giganews.com!nntp.giganews.com!buffer2.nntp.ams1.giganews.com!news.giganews.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Fri, 30 Apr 2021 14:04:38 -0500 |
| Newsgroups | fr.comp.lang.python |
| Subject | Re: Somme, récursive |
| X-poster | PEAR::Net_NNTP v1.5.0 (stable) |
| From | raph14 <nospam_rgb.baralle@gmail.com.invalid> |
| References | <48-dnbOA4f2klhb9nZ2dnUU7983NnZ2d@giganews.com> <87mttgakrp.fsf@izac.org> <s6h6e3$k80$1@cabale.usenet-fr.net> <s6h72u$mo6$1@cabale.usenet-fr.net> <87im43abkm.fsf@izac.org> |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 8bit |
| Organization | !No_Organization! |
| Message-ID | <bPmdnVxpYv1byRH9nZ2dnUU7983NnZ2d@giganews.com> (permalink) |
| Date | Fri, 30 Apr 2021 14:04:38 -0500 |
| Lines | 34 |
| X-Usenet-Provider | http://www.giganews.com |
| X-Trace | sv3-o3HDCM9LiTOcWFKKi71h0XFor6aCZ6DfqOOI1vZWsRwSTQC+zWMhei/Yb2F0McKMpxDzaSKTTBTZdJa!ibjtCAnOswEFR1ezFvLG6bXLVPjUQu8+zhzuduLb0KKf673p5UA+GpeDItfjLfoGlK7mXSPv6JhZ |
| 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-Bytes | 2164 |
| Xref | csiph.com fr.comp.lang.python:3495 |
Show key headers only | View raw
Le vendredi 30 Avril 2021 à 20:09 par Benoit Izac :
> Bonjour,
>
> Le 30/04/2021 Í 17:17, Olivier Miakinen a écrit dans le
> message
>
>
>> Méthode récursive :
>> =======================================> def somme(liste):
>> if len(liste) == 0:
>> return 0
>> return liste[0] + somme(liste[1:])
>> ====================================== C'est exactement ce que j'aurais
fait.
>> Je suis d'accord que c'est pourri
>>
> de créer une nouvelle liste Í chaque fois mais, vu que
> c'est déjÍ pourri
> de le faire en recursif en Python, on n'est pas Í ça
> près.
>
> --
> Benoit Izac
J'ai finis par réussir, voici le code pour ceux qu'ils le veulent :)
Et merci encore pour votre aide.
T = [4,7,5,5,2,6,9,3,8,4]
def somme(liste,result=0):
if len(liste)<=0:
return result
else:
result+=liste[0]
del liste[0]
return somme(liste, result)
Pour une pyramide contenant "4,7,5,5,2,6,9,3,8,4"
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Somme, récursive raph14 <nospam_rgb.baralle@gmail.com.invalid> - 2021-04-29 14:38 -0500
Re: Somme, récursive Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2021-04-29 22:38 +0200
Re: Somme, récursive Dominique <zzz@aol.com.invalid> - 2021-04-30 07:02 +0200
Re: Somme, récursive Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2021-04-30 12:07 +0200
Re: Somme, récursive raph14 <nospam_rgb.baralle@gmail.com.invalid> - 2021-04-30 09:56 -0500
Re: Somme, récursive raph14 <nospam_rgb.baralle@gmail.com.invalid> - 2021-04-30 09:57 -0500
Re: Somme, récursive Olivier Miakinen <om+news@miakinen.net> - 2021-04-30 17:06 +0200
Re: Somme, récursive Olivier Miakinen <om+news@miakinen.net> - 2021-04-30 17:17 +0200
Re: Somme, récursive Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2021-04-30 18:14 +0200
Re: Somme, récursive raph14 <nospam_rgb.baralle@gmail.com.invalid> - 2021-04-30 11:46 -0500
Re: Somme, récursive Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2021-04-30 20:09 +0200
Re: Somme, récursive raph14 <nospam_rgb.baralle@gmail.com.invalid> - 2021-04-30 14:04 -0500
Re: Somme, récursive Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2021-04-30 21:15 +0200
Re: Somme, récursive debimax <debimax@free.fr> - 2021-04-30 15:03 +0200
Re: Somme, récursive Dominique <zzz@aol.com.invalid> - 2021-04-30 18:46 +0200
Re: Somme, récursive debimax <debimax@free.fr> - 2021-04-30 22:05 +0200
Re: Somme, récursive Dominique <zzz@aol.com.invalid> - 2021-05-01 04:39 +0200
csiph-web