When you use Python, you must use the correct modules to do what you want.
To find all files in a directory with extension shp, for example, there are much simpler solutions that was presented without the break, which is awful...(as the solution presented by Nathan W, but there are many, many others, just search on Internet)
Some examples with relevant modules:
1) with the glob module:
for files in glob.glob("*.shp"):
shapefiles and geodatabases:
types = ('*.shp', '*.gbd') # the tuple of file types
files_grabbed = 
for files in types:
files_grabbed.extend(glob.glob(files)) #files_grabbed = the list of shp and gbd files
if you want to search also in the subdirectories:
for f in glob.iglob("/mydir/*/*.shp"): #search immediate subdirectories
2) with os.listdir and list comprehension (in two lines) -> list of results
path = 'mydir'
shape_files = [f for f in os.listdir(path) if f.endswith('.shp')]
gdb_files = [f for f in os.listdir(path) if f.endswith('.gdb')]
3) with fnmatch module:
for file in os.listdir('path'):
if fnmatch.fnmatch(file, '*.shp'):
and many others solutions, recursive etc.