M
M
micsma2020-09-08 19:43:48
Python
micsma, 2020-09-08 19:43:48

How to do if list < int,. .. ?

@client.command(aliases=['flip', 'coin'])
async def coinflip(ctx, amount = None, mount = int(100)):
#	cursor.execute("SELECT cash FROM users ORDER BY Name LIMIT 3")
#	monney = cursor.fetchall()
#	result_money = [str(item) for item in monney]
  coinsides = ['Орёл', 'Решка']
  result = random.choice(coinsides)
  await ctx.message.add_reaction('✅')
  if amount is None:
    await ctx.send(f"**{ctx.author}**, укажите на что вы ставите!")
#	if result_money < list(mount):
#		await ctx.send(f"**{ctx.author}**, у вас недостаточно денег для игры в монетку")
  else:
    if amount is None:
      await ctx.send(f"**{ctx.author}**, укажите сумму, которую желаете начислить на счёт пользователя")
    elif mount < 100:
      await ctx.send(f"**{ctx.author}**, укажите сумму больше чем **100** :money_with_wings:")
    if amount == 'Решка':
      print("РЕШКА!!")
      if result == 'Орёл':
        print("Вы проиграли. Выпал Орёл")
        await ctx.send(f"**{ctx.author}**, вы проиграли **{mount}**. Выпал Орёл!")
        cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(mount, ctx.author.id))
        connection.commit()
      if result == 'Решка':
        print("выпала решка, как вы и думали.")
        await ctx.send(f"**{ctx.author}**, выпала Решка. Вы выйграли **{mount}**!")
        cursor.execute("UPDATE users SET cash = cash + {} WHERE id = {}".format(mount, ctx.author.id))
        connection.commit()
    if amount == 'Орёл':
      print("ОРЁЛ!!")
      if result == 'Орёл':
        print("выпал орёл, как вы и думали.")
        await ctx.send(f"**{ctx.author}**, выпал Орёл. Вы выйграли **{mount}**!")
        cursor.execute("UPDATE users SET cash = cash + {} WHERE id = {}".format(mount, ctx.author.id))
        connection.commit()
      if result == 'Решка':
        print("Вы проиграли. Выпала Решка")
        await ctx.send(f"**{ctx.author}**, вы проиграли **{mount}**. Выпала Решка!")
        cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(mount, ctx.author.id))


How to make it so that if 'cash' from the 'users' list is less than the number,
then output the words 'You don't have enough money to play coin'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
cython, 2020-09-08
@cython

Sum all the values ​​from the monney list, then check that the summed value is greater than or equal to amount. Otherwise, display the specified message.

S
Sergey Tikhonov, 2020-09-08
@tumbler

UPDATE users SET cache = cache - {} WHERE cache > {} AND id = {}

If the cursor returns 0 changed records, the balance is not enough.
With a plus, you also need to check by the way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question