Path: ...!news.mixmin.net!aioe.org!EIHAHS7HsjDij55hoUn2SA.user.46.165.242.91.POSTED!not-for-mail From: Dominique Newsgroups: fr.comp.lang.python Subject: Autre exercice : calculer la somme de x chiffres. Date: Sun, 22 May 2022 17:00:26 +0200 Organization: Aioe.org NNTP Server Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="29192"; posting-host="EIHAHS7HsjDij55hoUn2SA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: fr X-Notice: Filtered by postfilter v. 0.9.2 Bytes: 1322 Lines: 16 Je trouve ce script qui fonctionne très bien et qui est en accord avec (n²+n)/2 : def addition(x): return sum([i for i in range(0,x+1)]) print (addition(int(input('Fin de la sommielle ')))) Est-ce propre ? Chercher la concision à tout prix est-ce un bon pari ? Je suis de l'ancienne école : j'ai commencé à programmer avec un Sharp PC1211 qui avait 1 KO de RAM. On apprenait à compacter... Merci pour votre éclairage, Dominique