You will need to use a multiprocessing library. You will need to spawn a new process and provide the code to it as an argument. For example,
from multiprocessing import Process
def loop_a():
for i in range(5):
print("a")
def loop_b():
for i in range(5):
print("b")
Process(target=loop_a).start()
Process(target=loop_b).start()This might process different outputs at different times. This is because we don't know which print will be executed when.