Jones Malone
Jones Malone

Reputation: 1

Python list.append not working. I'm using discord.py and replit database to make a gambling bot and I wanted a list of participants

So basically I'm trying to get a discord betting bot to give a list of participants that it can cycle through when games end. The problem is that when I use this code it doesn't seem to append. I've tried debugging it using an alt. The not in db['list'] part triggers fine, and there are no errors raised, but the list still only contains my main account's ID (which was used to create the list.)

The repl.it database is basically a big array with string indexes / keys. I'm sure that lists are an accepted data type since when I debugged before it printed db['list'] as ['#MYIDNUMBER'] but it still won't append my alt's.

    db['list'] = [str(message.author.id)]
    db['betenable'] = True
  if message.content.startswith('$createaccount'):
    db[str(message.author.id)+'wallet'] = 1000
    db[str(message.author.id)+'ingame'] = 0
    db[str(message.author.id)+'bet'] = 'No Party'
    if str(message.author.id) not in db['list']:
      db['list'].append(str(message.author.id))```

Upvotes: 0

Views: 521

Answers (1)

Albert
Albert

Reputation: 550

You're accessing db[list], using the list built-in, instead of the string, db['list'].

Upvotes: 1

Related Questions