0

iterating dict keys in a for loop gives (correctly or as desired):

>>> for ky in myDict.keys():
...     print(ky)
...
a1
a2
a3
a4
a5
a6

Whereas -- putting in a comprehension gives -- why the list of None??:

>>> [print(ky) for ky in myDict.keys()]
a1
a2
a3
a4
a5
a6
[None, None, None, None, None, None]
Barmar
  • 741,623
  • 53
  • 500
  • 612
bhall
  • 1

1 Answers1

-2

print is a function that has None as a return value.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
phi friday
  • 191
  • 4