0

I have a "schema" array in python that looks like this:

schema = ['id', 'username', 'password', 'email', 'token','cooldown', 'membership', 'tos']

and a "types" array which looks like this:

types = ["email", "username", "password"]

What I have to do is compare the "schema" array against the "types" array and remove any array objects from "schema" that arent in "types" and keep the ones that are.

Heres how I went about doing this:

for schemaparam in schema:
   if (schemaparam in types) == False: #if the param isnt a valid type
      index_to_delete = schema.index(schemaparam)
      schema.pop(index_to_delete)

But I only later realised that when I remove something from an array, everything after it will have a different array index.

How can I do this properly?

ste
  • 3
  • 5

0 Answers0