Need help deleting keys

i know how to delete a single key but i want to delete them all, how do i do that.
i tried this code:

from replit import db

keys = str(db.keys())[1: -1]

del db[keys]

: the printing works but it doesn’t delete any thing it gives me an error.


Try doing a for loop

1 Like

You could use a for loop, but replit db has a nice function called db.clear(), which does the same thing with less space.


I just do:

for x in db.keys():
  del db[x]
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.