Is there any way to do this in a single line, but without using a 'None'?:
folders = ['Project 1', 'Project 2']
files = os.listdir('/home/user/Documents/Python')
for i in files:
files.remove(i) if i in folders else None
Could one 'skip' the 'else' statement?
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…