for i in range(1, 1000+1): with open('fibonacci_{0}.txt'.format(i), 'w') as f: a = 1 b = 1 while a < 10000: print(a, file=f) a, b = b, a+b import os vse_datoteke = os.listdir('.') # print(vse_datoteke) for ime in vse_datoteke: if ime.startswith('fibonacci_'): os.remove(ime)