[英]Im trying to make a code where a person will bet on a number which is randomly generated b/w 1, 6 but even if i get it correct the it says that I lost
我试图制作一个代码,一个人会在一个随机生成的 b/w 1, 6 数字上下注,但即使我猜对了,它也说我输了
#importing the needs
import discord
import random
from discord.ext import commands
client = discord.Client()
client = commands.Bot(command_prefix='%')
r = [1, 2, 3, 4, 5, 6]
@client.event
async def on_ready():
print('we are ready')
@client.command()
#getting the input from the user
async def play(ctx, a):
await ctx.send('Type the number you bet on ')
r = random.randint(1, 2)
#checking if the input is equal to the randomly generated number
#Here is where the problem is
if a == r:
await ctx.send('you won ' + str(r) + ' you chose ' + str(a))
else:
await ctx.send('you lost ' + str(r) + ' you chose ' + str(a))
这可能是因为接收到的值和随机整数属于不同类型。
尝试类型转换如下:
if int(a) == r:
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.