We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
No it is not, this means, that print() will be called n-times instead of once.
Besides that you need to keep in mind that any function or method in python always returns None unless it is told explicitly to return something else.
In your solution, the list comprehension will return a list of length n, where each item is None.
>>> n = 5
>>> [print(i**2) for i in range(n)]
0
1
4
9
16
[None, None, None, None, None]
Loops
You are viewing a single comment's thread. Return to all comments →
No it is not, this means, that print() will be called n-times instead of once.
Besides that you need to keep in mind that any function or method in python always returns None unless it is told explicitly to return something else. In your solution, the list comprehension will return a list of length n, where each item is None.