【问题标题】:bot returning the wrong numberbot returning the wrong number
【发布时间】:2022-12-01 22:17:46
【问题描述】:

I'm Trying to make a tax calculator but it's returning something strange.. Here's the function:

async def tax(args):
  args3 = 5
  protax= round(int(args)*args3/100)
  if protax == 0:
    protax = 1
  return protax

here is where I call the function:

    c.execute("SELECT price FROM netflix ")
    netfprice = c.fetchall()
    netprice = netfprice[0][0]
    newnet = netprice*amount
    withtax = await tax(args=newnet)
embed = discord.Embed(
      title="tax system",
      description=f"tax:{netprice + withtax}")
    embed.set_footer(text=f"Sidtho Host. | Requested by - {message.author}")
    await message.respond(embed=embed)

For this example let's use amount = 2, netprice = 3999.

It returned 4199, but should've returned 7998 + 400, So 8398.

【问题讨论】:

  • Did you post all of the relevant code? With your example values, the function should've returned 400.
  • No I didn't wait let me edit the code. Sorry, By the way: I did make it send netprice + withtax
  • Since you print netprice + withtax, again, it should have printed 4399 (neither 4199, nor 8398). Which output do you expect to be 8398? What function returns, or what you have in description sting?
  • Yeah true it was 4399 Sorry for my mistakes. I expected description to return 8398, and the tax func to calculate
  • Okay I feel really dumb after seeing my mistake ... I found it

标签: python discord.py pycord


【解决方案1】:

I feel really dumb after seeing my mistake... my mistake was in the embed description.. Here:description=f"tax:{netprice + withtax}")

I should've made it description=f"tax:{newprice + withtax}")

【讨论】:

    猜你喜欢
    • 2022-12-16
    • 2022-12-15
    • 2016-03-02
    • 2018-02-12
    • 1970-01-01
    • 2022-12-01
    • 2022-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多