[英]How can I keep track of a list in discord.py
Here's my code这是我的代码
amount = 0
list = []
#b is the client
@b.command()
async def hello(ctx):
if list == []:
list.append("9")
list.append("10")
list.append("11")
list.append("12")
else:
amount += 1
print(list[amount])
So there's a couple things I want to do, every time I run the command through discord I want it to add 1 to the amount, I also want the things that I appended in the command to be permanently added to the list as those values will change every time I run the command.所以我想做几件事,每次我通过 discord 运行命令时,我希望它在数量上加 1,我还希望我在命令中附加的内容永久添加到列表中,因为这些值将每次运行命令时都会更改。
This is an example of what I want to print out:这是我要打印的示例:
After I run it once:我运行一次后:
9
After I run it twice:在我运行两次之后:
10
After I run three times:我跑三遍后:
11
something like this?像这样的东西? (dis.py questions arent necessarily accessible to test immediately)
(dis.py 问题不一定可以立即进行测试)
lst = []
#b is the client
@b.command()
async def hello(ctx):
if not lst:
lst.append(9)
else:
last = lst[-1]
await ctx.send(last)
lst.append(last + 1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.