lundi 8 mai 2017

Use switch case in python with special condition

i have this:

if you == 1:
    one.put(argument)
elif you == 3:
    pass
elif you == 4:
    two.put(argument)
elif you == 5:
    three.put(argument)
...
...
...
a lot of elif

I am trying to use dictionary:

settings = {
    1: one
    4: two,
    5: three
    ...
    ...
    ...
    other elemets of dict
    }

    if you in settings:
        settings[you].put(argument)

Everything is ok, but i have no idea, how to add this in dictionary:

elif you == 3:
    pass

How you think, what the better way to add pass statement to dictionary ?

Aucun commentaire:

Enregistrer un commentaire