d['fruit'] if 'fruit' in d and d['fruit'] in fruit else ''
d['fruit'] = 'watermellon'
d['fruit'] if 'fruit' in d and d['fruit'] in fruit else ''
Testing whether a value is in a set and assigning variable