I am looking for a way to use if else condition in a dictionary to set a value to a key. Is there a way?
The example below might help you understand what I want to do. This is not a functional python code. Just an example to give you an idea.
age = 22
di = {
'name': 'xyz',
if age>=18:
'access_grant': 'yes',
else:
'access_grant': 'no',
}
Comment if you don't get the question. please don't downvote.
Aucun commentaire:
Enregistrer un commentaire