I'm trying to understand List-comprehensions in python , I came across this behaviour of list comprehension. when I do:
[print(y) for y in range(0,10)]
it gives response
0
1
2
3
4
5
6
7
8
9
[None, None, None, None, None, None, None, None, None, None]
I understand it prints 0 to 9, but I don't understand why it prints None
.But when I do o = [print(y) for y in range(0,10)]
it prints
0
1
2
3
4
5
6
7
8
9
This time without any none
,I couldn't find any relevant stuff by searching, can someone please explain , Thanks