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]
print(keys)

del db[keys]

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

2 Likes

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.

4 Likes

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.