how to get only non-blank entry of list in python 1

how to get only non-blank entry of list in python

",".join(string for string in lst if len(string) > 0)

Here is what the above code is Doing:
1. We’re using a list comprehension to create a list of strings.
2. We’re using the join method to join the strings in the list together.
3. We’re using a conditional to only join strings that are longer than 0 characters.

Similar Posts