Ask coding questions

← Back to all posts
How can I add multiple values into one key
suomelaeelis

So I am making a reddit bot. so if someone replies the bot then it would take the username and add it to the database. but how can I add many users/values to one key?

Answered by VulcanWM [earned 5 cycles]
View Answer
Voters
suomelaeelis
Comments
hotnewtop
VulcanWM

you can make the key value a list so set it as ['value1', 'value2']

suomelaeelis

But how I make that it knows to change the value 1 to value 2 and so on? @VulcanWM

VulcanWM

you can use the index of the list to know what the value is @suomelaeelis

suomelaeelis

I dont quite understand that. I mean that if someone replies my bot it will add it to the database automatically but how can I make it that it adds it to the same [email protected]

VulcanWM

if you invite me to ur repl i can try to help @suomelaeelis

suomelaeelis

okay wait a [email protected]

suomelaeelis

sent 5 mins [email protected]

VulcanWM

replitdb doesnt work let keys be lists, so you can set all of the users as a string and then separate it with something @suomelaeelis