Python: Check if object exists in Blender 2.8
Best practice is iterating through Scene.objects collection (all objects of the current scene):
import bpy

for o in bpy.context.scene.objects:
    if o.name == &quot;Cube&quot;:
        print (&quot;Cube found in scene&quot;)

Even easier to read is using python's get() on the actual collection to get the reference:
cube = bpy.context.scene.objects.get(&quot;Cube&quot;)
if cube:
    print (&quot;Cube found in scene&quot;)

Recommend use the python console to figure out:
&gt;&gt;&gt; C.scene.objects.get(&quot;Cube&quot;)
bpy.data.objects['Cube']

Alternatively you can also iterate through Data.objects (all objects of the actual file using):
&gt;&gt;&gt; D.objects.get(&quot;Cube&quot;)
bpy.data.objects['Cube']

For the sake of completeness, demo on how to get all objects starting with &quot;Cube&quot;:
import bpy

objs = []
for o in bpy.data.objects:
    if o.name.startswith(&quot;Cube&quot;):
        objs.append(o)

if objs:
    print (&quot;Cube found {} time(s) in file&quot;.format(len(objs)))
    

Related: Python: Selecting object by name in 2.8