Please help me

hey guys , if u can help me please , i am trying to build a website with streamlit for a school project,
it’s a bitcoin tracker . the first thing i want to do is have a converter from bitcoin to usd and vice versa , i have the python code but i dont know how to proceed , any ideas. here is the python code:
import requests

url = “https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR”

response = requests.get(url).json()

price = response[“USD”]

def convert_to_USD(x) :

somme = price*x

return somme

print(convert_to_USD(1),“USD”)

def convert_to_BTC(x) :

s = x/price

somme = round(s,6) 

return somme

print(convert_to_BTC(1),“BTC”)

Hi @oumaima,

The question is not really about Streamlit. Perhaps this question might be better of on stackoverflow.
Also, if you ask questions and post code that is not working, please include the error message and what the expected behaviour is.

Anyway, you seem to use wrong quotation marks in your code. Suggest you check you local language and keyboard settings.

import requests

url = "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR"

response = requests.get(url).json()

price = response["USD"]

def convert_to_USD(x) :
    somme = price*x
    return somme

print(convert_to_USD(1),"USD")

def convert_to_BTC(x) :
    s = x/price
    somme = round(s,6) 
    return somme

print(convert_to_BTC(1),"BTC")
1 Like

thank you for the advice and btw this is what i recieve
script error

1 Like

This is still not pasting the error message. This is show a screen shot of half the error message.

Since the syntax error is at the beginning of line 28 I suspect the error is in the previous line of code.
Could be you forgot closing quotation marks / parentheses / brackets / etc.

1 Like

FYI, the code runs perfectly for me: Here is the output:

60883.28 USD
1.6e-05 BTC

As @maarten-betman said above, the issue is to do with the string

url = ...

As tedious as it sounds, try copying it to a word document, then typing that url line into your code manually.

1 Like