[Answered ]-How to solve "IndexError at / list index out of range" when there is an empty list

1👍

You can work with a ternary operator:

for i in data['result'].values():
    kraken_data = Kraken.objects.create(
        altname = i['altname'], 
        leverage_buy = i['leverage_buy'][0] if i['leverage_buy'] else None
    )

Leave a comment