[Tutor] Change dictionary value depending on a conditionalstatement.
Norman Khine
norman at khine.net
Sun Feb 10 20:09:07 CET 2008
thanks
Tiger12506 wrote:
> >>> list = []
>>>>> total = 0
>>>>> if total > 0:
>> ... x = {'id': 'name', 'link': 'XX'}
>> ... list.append(x)
>> ... else:
>> ... y = {'id': 'name', 'link': 'YY'}
>> ... list.append(y)
>> ...
>>
>
> Yeah.
>
> list = []
> x = {'id':'name'}
> if total > 0:
> x['link'] = 'XX'
> else:
> x['link'] = 'YY'
> list.append(x)
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list