On Wed, Oct 28, 2015 at 11:25 AM, Larry Martell <larry.mart...@gmail.com> wrote:
> I'm trying to do a list comprehension with an if and that requires an
> else, but in the else case I do not want anything added to the list.
>
> For example, if I do this:
>
> white_list = [l.control_hub.serial_number if l.wblist == wblist_enum['WHITE'] 
>  else None for l in wblist]

Switch the 'if' and the 'for':

   white_list = [l.control_hub.serial_number for l in wblist if
l.wblist == wblist_enum['WHITE']]

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to