0
Is the expression inside the [..] compilable for others expressions ?
Such as ; print(i**3) for i in range(11)
5 Answers
+ 2
[print(i**3) for i in range(11)]
[repr(i**3) for i in range(11)]
"In Python 2, print is a statement, not a function"
https://docs.python.org/2.7/reference/simple_stmts.html#print
Seems nobody has given a deeper reason.
+ 1
Because you forgot the set of opening and closing parenthesis and put an extra one in.
print(i**3 for i in range(11))
+ 1
d = {}
[d.update({i:i}) for i in range(11)]
[d[i]=i for i in range(11)]
a = lambda x: 1
a = lambda x: x=1
Finally found a clear explanation!đ€Ł
"A statement in Python is a line of code that provides instruction or commands for Python to perform. A statement never returns any value.
Functions on the other hand are a collection of statements that when called perform an intended action. They are organized and reusable in nature. Functions always return a value."
https://www.pylenin.com/blogs/python-print/
0
Did you try it or just ask blindly?
0
I've try on different compiler it seems to not work but i don't understand why ?