In [5]:
import os
import glob

In [6]:
os.getcwd()


Out[6]:
'C:\\Users\\Dell'

In [7]:
path = 'C:\\Users\\Dell\\Downloads'

In [8]:
extension = 'csv'
os.chdir(path)

In [9]:
result = [i for i in glob.glob('*.{}'.format(extension))]
print(result)


['AirPassengers.csv', 'BigDiamonds.csv', 'Boston (1).csv', 'Boston.csv', 'ccFraud.csv', 'class2.csv', 'data1.csv', 'datasets.csv', 'Diamond (1).csv', 'Diamond (2).csv', 'Diamond (3).csv', 'Diamond (4).csv', 'Diamond (5).csv', 'Diamond (6).csv', 'Diamond.csv', 'Hdma.csv', 'Hedonic.csv', 'pgd.csv', 'protein.csv', 'RidingMowers.csv', 'sales-of-shampoo-over-a-three-ye.csv', 'telecom.csv']

In [ ]: