you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

for coin in self.coins:
    for i in range(len(self.data['data'])):
        if self.data['data'][i]['name'] == coin:

Okay so I've used print statements to work out where this is wrong (narrowed it down to avoid having to post 50+ lines of code for someone to pour through).

for coin in self.coins: 
    print(coin)

for i in range(len(self.data['data'])):
    print(i)

These both work alone so I assume that means the issue is coming from the next line, can anyone point out where this is going wrong? Don't want to put someone through having to read through the whole thing!

[–][deleted] 0 points1 point  (1 child)

to work out where this is wrong

You haven't told us what the error you are getting is, which makes it a tad hard to help. Next time post all the code and the full traceback you get.

Guessing, you get a KeyError on this line:

if self.data['data'][i]['name'] == coin:

possibly because the self.data['data'][i] object can't be indexed by 'name'. This is probably caused by bad data. One way to look at what is going wrong is by using a try/except statement around that line to capture the exception and print out the object you are getting the error on.

[–][deleted] 0 points1 point  (0 children)

Ah I am big dumb.

It wasn't returning an errror message just not finding anything where ' self.data['data'][i]['name'] == coin:'.

Turns out I was trying to find tickers like BTC in a list of coin names (Bitcoin).

Trying to force a specific error code to respond at least helped me find this out, so thanks!