Home > Back-end >  Can not concactenate str ("not list")?
Can not concactenate str ("not list")?

Time:09-07

I get an error which is TypeError: can only concatenate str (not "list") to str. How do I join all addresses together with a separator using "|" ?

def make_api_url(**kwargs):
        data = pd.read_csv('bitcoinaddr.csv')
        Wallet_Address = (data.loc[:, "Address"])
        BASE_URL = "https://blockchain.info/balance"
        print (Wallet_Address)
        for address in Wallet_Address:
            print (address)
            url = BASE_URL   [f"?active={address}"] #error
            print(url)
        
        for key, value in kwargs.items():
             url  = f"&{key}={value}"
             return url
    
    get_balance_url = make_api_url()

CodePudding user response:

I think you want:

address = '|'.join(Wallet_Address)
url = BASE_URL   f"?active={addresses}"

That is, build the pipe separated string of addresses first, then append it one time to the URL as a query parameter.

  • Related