Список понимания - списки файлов с расширением в каталоге

a = [name for name in os.listdir(".") if name.endswith(".txt")]
Mushy Manx