How to remove level from Levels list with python code?

I want to implement this level removal feature in python code!
I hope you can give me some advice, thank you very much!

Hey, any luck with this? I really need this too