I use this script to get crypto prices:
from pycoingecko import CoinGeckoAPI
import json
cg = CoinGeckoAPI()
response = cg.get_price(ids='bitcoin', vs_currencies='usd')
print(response)
token = response.get('bitcoin','')
print(token)
and the output returned is:
{'bitcoin': {'usd': 60302}}
{'usd': 60302}
How can I get just the value 60302 instead of the full column?
token['bitcoin']['usd']try this