Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70038 > unrolled thread

Re: why i have the output of [None, None, None]

Started bySkip Montanaro <skip@pobox.com>
First post2014-04-10 09:12 -0500
Last post2014-04-10 09:12 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: why i have the output of [None, None, None] Skip Montanaro <skip@pobox.com> - 2014-04-10 09:12 -0500

#70038 — Re: why i have the output of [None, None, None]

FromSkip Montanaro <skip@pobox.com>
Date2014-04-10 09:12 -0500
SubjectRe: why i have the output of [None, None, None]
Message-ID<mailman.9136.1397139154.18130.python-list@python.org>
The print function in Python 3 returns None. The "ok" output is a side
effect. The actual value of evaluating that list comprehension is a
list of three None values.

Skip

On Thu, Apr 10, 2014 at 8:54 AM, length power <elearn2014@gmail.com> wrote:
>>>> x=['','x1','x2','x3','   ']
>>>> x
> ['', 'x1', 'x2', 'x3', '   ']
>>>> [print("ok") for it in x if it.strip() !=""]
> ok
> ok
> ok
> [None, None, None]
>
> i understand there are three 'ok' in the output,but why i have the output of
> [None, None, None]
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web