multiple actions in list comprehension python

You can use tuple for doing that job like this:

[(print("bla1"), print("bla2")) for i in list]

it's work correctly.


Don't use list comprehension for commands. List comprehensions are for creating lists, not for commands. Use a plain old loop:

for i in list:
    print('bla1')
    print('bla2') 

List comprehensions are wonderful amazing things full of unicorns and chocolate, but they're not a solution for everything.


In some cases, it may be acceptable to call a function with the two statements in it.

def f():
   print("bla1")
   print("bla2")

[f() for i in l]

Can also send an argument to the function.

def f(i):
   print("bla1 %d" % i)
   print("bla2")

l = [5,6,7]

[f(i) for i in l]

Output:

bla1 5
bla2
bla1 6
bla2
bla1 7
bla2