我使用以下代码创建一个积分表:
@bot.command()
async def start(ctx):
await ctx.send("How many total teams are there?")
t = await get_input_of_type(int, ctx)
embed = discord.Embed(title="**__Today's Result:__**", color=0x03f8fc)
lst = []
for i in range(t):
await ctx.send(f"Enter team {i+1} name :")
teamname = await get_input_of_type(str, ctx)
await ctx.send("How many kills did they get?")
firstnum = await get_input_of_type(int, ctx)
await ctx.send("How much Position points did they score?")
secondnum = await get_input_of_type(int, ctx)
lst.append((teamname, firstnum, secondnum)) # append to results
lstSorted = sorted(lst, key = lambda x: int(x[1]) + int(x[2])) # sort results by kills + points
for teamname, firstnum, secondnum in lstSorted: # process embed
embed.add_field(name=teamname, value=f'Kills: {firstnum}\nPosition Pt: {secondnum}\nTotal Pt: {firstnum+secondnum}',inline=False)
await ctx.send(embed=embed)
问题是代码运行良好,但我希望它根据总分按降序对结果进行排序,但这不起作用,我不知道我在这里做错了什么
另外,如果你能为我提供一些更好的可视化结果的建议,我们非常欢迎你。 谢谢
目前没有回答
相关问题 更多 >
编程相关推荐