Lista rozumienia - lista plików z rozszerzeniem w katalogu

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