I am gettting the following error when i run the code to extract the current price of bitcoin
The code is:
import requests,json
def get_bitcoin_price():
URL = “https://min-api.cryptocompare.com/” # REPLACE WITH CORRECT URL
response = requests.request(“GET”, URL)
response = json.loads(response.text)
current_price = response[“USD”]
return current_price
print(get_bitcoin_price())
and output i get is:
Traceback (most recent call last):
File “C:/Users/Personal/AppData/Local/Programs/Python/Python37-32/bitcoin_proj.py”, line 8, in
print(get_bitcoin_price())
File “C:/Users/Personal/AppData/Local/Programs/Python/Python37-32/bitcoin_proj.py”, line 5, in get_bitcoin_price
response = json.loads(response.text)
File “C:\Users\Personal\AppData\Local\Programs\Python\Python37-32\lib\json_init_.py”, line 348, in loads
return _default_decoder.decode(s)
File “C:\Users\Personal\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Users\Personal\AppData\Local\Programs\Python\Python37-32\lib\json\decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)