mercredi 2 septembre 2020

Using the dictionary and Confirming keys according to value

I tried to Create a dictionary called seasons with keys as the four seasons and values as the months of each season, i.e., 'Spring': [3,4,5]

    d={"Winter":[1,2,3],"Summer":[4,5,6], "Spring":[7,8,9],"Autumn":[10,11,12]}
    from numpy import random
    months = random.randint(1,13,10)

Now using the dictionary "Seasons" to determine which season each month in the array "months" belongs to.




Aucun commentaire:

Enregistrer un commentaire