How to find if object exit or not?

i can find object like this
but how do i test if it exist or not ?

name1 = “matercube”[name1

if it does not exist it gives an error
but how to test and get a true or false for exitance of the object ?

if it does not exist then i have to create a new one
but no material - mat will be added elsewhere

happy bl

if name in :
    #Object exists

basically any collection in blender have get() method and using item name to get item data


for example :

obj_cube ='Cube')
if obj is not None:
    print('cube exist')

will that get thing find object in all collections or only the enable one ?

happy bl

collection status (enable or exclude) in outliner does not effect to the object