Need Help With Python In Maya (Beginner Question)


#1

So recently I started learning python in Maya. What I’m trying to do now is type a short code that finds all items in my scene with a certain suffix and then deletes them.
Let’s say I have five joints all of them with the suffix “_JNT”. How could python find them and then delete them?


#2

Yo this is one way to do it:
Probably not the best way but should work:

import maya.cmds as mc
        
for i in mc.ls():
    if i.endswith('_JNT') and mc.objExists(i):
        mc.delete(i)