Python 3 - I am using a for loop to print values from a dictionary. Some dictionaries within rawData have "RecurringCharges" as an empty list. I am checking to see if the list is empty and either populating with "0.0" if empty or the "Amount" if populated.
Creating the IF statement in my For Loop presents a new print statement and prints to a new line. I would like it to be one continuous line.
for each in rawData['ReservedInstancesOfferings']:
print('PDX', ','
, each['InstanceType'], ','
, each['InstanceTenancy'], ','
, each['ProductDescription'], ','
, each['OfferingType'], ','
, each['Duration'], ','
, each['ReservedInstancesOfferingId'], ','
, each['FixedPrice'], ',',
)
if not each['RecurringCharges']:
print("0.0")
else:
print(each['RecurringCharges'][0].get('Amount'))