SyntaxFix
Write A Post
Hire A Developer
Questions
Look at module fnmatch. That will do what you're trying to do.
import fnmatch import os for file in os.listdir('.'): if fnmatch.fnmatch(file, '*.txt'): print file