Feb-25-2018, 09:57 AM
(Feb-23-2018, 12:57 PM)buran Wrote:>>> x = 'running' >>> status = x == 'running' and 'OK' or 'Failed' >>> status 'OK' >>> x = 'stopped' >>> status = x == 'running' and 'OK' or 'Failed' >>> status 'Failed' >>>alternative
statuses = {'running': 'OK'} for reservation in desc['Reservations']: for instance in reservation['Instances']: status = statuses.get(instance['State']['Name'], 'Failed')Of course good old if/else would also do the job
Thank you so much buran ! the problem resolved :)