samedi 8 août 2015

Python - How to use if statement in dictionary

I was trying to do this, but It didn't work. Just to clarify I want value to equal list[0] if it exists. Thanks.

    dictionary = {
    try:
        value : list[0],
    except IndexError:
        value = None
    }

Aucun commentaire:

Enregistrer un commentaire