Why is print(x) here not valid (SyntaxError) in the following list-comprehension?
print(x)
SyntaxError
my_list=[1,2,3] [print(my_item) for my_item in my
print in python 3 makes it more obvious on how to use it.
the square brackets in the list comprehension denotes that the output will actually be a list. L1=['a','ab','abc'] print([item for item in L1]) This should do the trick.
L1=['a','ab','abc'] print([item for item in L1])