javierkid javierkid - 1 year ago 101
Python Question

Using the List Feature in Python

month_days= [('January',[31]),('February',[28,29]),('March',[31]),


('September',[30]),('October',[31]),('November',[30]),('December',[31]) ]

day_names =

Problem 1
Write a function days_in_month which takes a month as an argument and finds the
corresponding month in the month_days list and returns the number of days associated with that
Im open for explanations aswell

Answer Source
def days_in_month(month):
    for m, nblist in month_days:
        if month==m:
            return nblist
        return []

Out[20]: [31]

Out[21]: []
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download