I don't know how to be a beginner
for i in textname:
if 'txt' in i:
textfile.append(i)
There's also a function. There's a function called filter.
textfile = filter(lambda e: 'txt' in e, textname)
Or you can write in one line as a list compliance.
textfile = [ e for e in textname if 'txt' in e ]
© 2024 OneMinuteCode. All rights reserved.