Ask coding questions

← Back to all posts
First letter of db key shows up in key error.
catspython (27)

I am making a quiz to post on talk. I have a, function, adqu() (add question) It takes 3 things, qu(question), op1(option 1), and op2, then it runs this,
db[qu] = [qu,op1,op2]
so, is it because I'm putting a list in data base?
I can't do anything with them, it gives a key error like this:

(The key is "catssss" or something)
The only way to delete them is to fork the repl.
so can you help?
P.S. The function is in a file called ''

Answered by Coder100 (17018) [earned 5 cycles]
View Answer
Coder100 (17018)

o is the first letter of the key. Unless it exists (which it doesn't), you have to do:

questions = db.keys()
for question in questions:

did you mean to access the first item of the value of the key?

questions = db.keys()
for question in questions:

differences people, differences.

catspython (27)

@Coder100 I have added to your GIANT stockpile of cycles.

FishballNooodle (174)

You did the indexing wrong.
It should be db[question][0] for line 33