I have problem with discord.py TypeError: can only concatenate str (not "float") to str

DiabloStudio

I have a problem with creating a command to load information about the Bitcoin price.

Error in console: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "float") to str

Here is the code:

@client.command(pass_context=True)
async def bitcoin(ctx):
    url = 'http://api.coinlayer.com/live?access_key='
    async with aiohttp.ClientSession() as session:
        raw_response = await session.get(url)
        response = await raw_response.text()
        response = json.loads(response)
        await ctx.send("Bitcoin price is: $" + response['rates']['BTC'])

How can I fix it?

lllrnr101

Most likely your response['rates']['BTC'] is a float and therefore you can not directly concat it to a string using the +

User str() to convert it to str or use f-strings f"Bitcoin price is: $ {response['rates']['BTC']}"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TypeError: can only concatenate str (not "float") to str

TypeError: can only concatenate str (not "float") to str

TypeError: can only concatenate str (not "float") to str in a DataFrame

I'm receiving a TypeError: can only concatenate str (not "int") to str

TypeError: can only concatenate str (not "bytes") to str

TypeError: can only concatenate str (not "relativedelta") to str

Problem with can only concatenate str (not "NoneType") to str

String concatenate TypeError: can only concatenate str (not "int") to str"

TypeError: can only concatenate str (not "numpy.float64") to str data set question

TypeError: can only concatenate list (not "str") to list -

TypeError: can only concatenate list (not "str") to list

TypeError: can only concatenate list (not "str") to listt

I have no idea why I am getting "can only concatenate str (not "int") to str" ERROR here

Is there solution to this error "TypeError: can only concatenate str (not "NoneType") to str"?

TypeError: can only concatenate str (not "int") to str - (New Learner)

Discordbot TypeError: can only concatenate str (not "NoneType") to str

Python TypeError: can only concatenate str (not "bytes") to str

TypeError: can only concatenate str (not "list") to str - pandas

TypeError: can only concatenate str (not "int") to str SUM

TypeError: can only concatenate str (not "numpy.int64") to str

How to fix TypeError: can only concatenate str (not "list") to str

Python 3 - TypeError: can only concatenate str (not "bytes") to str

Error: TypeError: can only concatenate str (not "NoneType") to str

TypeError: can only concatenate str (not "bytes") to str in Python

scrapy Pipeline TypeError: can only concatenate str (not "dict") to str

Scrapy - TypeError: can only concatenate str (not "list") to str

Python: TypeError: can only concatenate str (not "list") to str

Currently getting an error TypeError: can only concatenate str (not "NoneType") to str

Data validation: TypeError: can only concatenate str (not "int") to str