Click here to Skip to main content
15,042,397 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
disList = [i for i in disList if i != '']

I have run across this line in my code and know that is used to remove blank values from a pre-established:

I was able to determine its intended result from the context of my own code.

However, it is a very cool little code for what was needed to be done and how fast it did it.

What is the "common name" of this type of list manipulation? I would love to learn more about the limits of what kinds of forLoops can be passed through square brackets. And where else forLoops can do this (tuples, dictionaries?)

1 solution

It is called list comprehension.[^]

Good luck!
PythonHeadBanger 12-Nov-15 12:25pm
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900