Deutsch   English   Français   Italiano  
<dLydnXMwVOCzfWf8nZ2dnUU7_83NnZ2d@giganews.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 02 Feb 2022 13:49:02 -0600
Newsgroups: fr.comp.lang.python
Subject: Simplifier le programme
X-poster: PEAR::Net_NNTP v1.5.0 (stable)
From: OverSkill <nospam_kadiyogohector@gmail.com.invalid>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit
Organization: !No_Organization!
Message-ID: <dLydnXMwVOCzfWf8nZ2dnUU7_83NnZ2d@giganews.com>
Date: Wed, 02 Feb 2022 13:49:02 -0600
Lines: 35
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-TU0fvJZFX5N6uHIXlPx9120JYpJAFm3xdDWB+ddWaBu5+hP8BBpjY8z0QH0UYEnACzMp8PdtBbhUoao!XmQFDtT3ny4EhSywlIJWNdO+2KCyUX3+bGPh4t1swj89tx7c+SAhaQLG9CzYBb9DCY8UWlJSrt55
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
Bytes: 2057
X-Original-Lines: 34

bonjour, je viens de finir un programme python pour un projet personnel mais
j'aimerais savoir s'il y a un moyen de le simplifier:

from datetime import *
month_days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]
push_ups = 0
today = date.today()
day = today.day
month = today.month
if month == 2:
    push_ups += month_days[0]
elif month == 3:
    push_ups += month_days[0:1]
elif month == 4:
    push_ups += month_days[0:2]
elif month == 5:
    push_ups += month_days[0:3]
elif month == 6:
    push_ups += month_days[0:4]
elif month == 7:
    push_ups += month_days[0:5]
elif month == 8:
    push_ups += month_days[0:6]
elif month == 9:
    push_ups += month_days[0:7]
elif month == 10:
    push_ups += month_days[0:8]
elif month == 11:
    push_ups += month_days[0:9]
elif month == 12:
    push_ups += month_days[0:10]
push_ups += day
print("Aujourd'hui, tu dois faire", push_ups, "pompes")

son but est de compter le combientième jour nous sommes dans l'année, si vous
avez une solution, merci d'avance