Understanding Python 3 lists printing None value for each element -
as noob in python i'm printing elements of list in version 3, , after comprehensive research couldn't find explanation kind of behavior.
however, know every function must return value , when it's not defined function returns "null" (or "none" in python). why in case, after printing elements correctly prints "none" each element in list?
>>> a_list = [1,2] >>> a_list [1, 2] >>> [print(f) f in a_list] 1 2 [none, none]
none return value of print function.
don't use [print(f) f in a_list] when mean for f in a_list: print(f).
Comments
Post a Comment