Skip to content Skip to sidebar Skip to footer

Making A Single-line 'if' Statement Without An 'else' In Python 3

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:

Solution 1:

if i in files: files.remove(i)


Post a Comment for "Making A Single-line 'if' Statement Without An 'else' In Python 3"