R
R
ReDeNDeR2021-08-13 15:19:25
Python
ReDeNDeR, 2021-08-13 15:19:25

Lists not working in Python, what should I do?

I'm trying to parse the json of the page, but it doesn't work. I'm taking json from a site, but when I try to interact with its elements, an error is shown.

Here is the code:

import requests

url = 'https://api.pancakeswap.info/api/v2/tokens/0x246bd5d18613519deffea90c05dd0068658f076b'
response = requests.get(url)

list = response.json()

print(list[1])

Mistake:
Traceback (most recent call last):
  File "D:\Coding\Test.py", line 8, in <module>
    print(list[1])
KeyError: 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-13
@ReDeNDeR

Because this is not a list, but a dictionary
https://pythonworld.ru/tipy-dannyx-v-python/slovar...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question