'Couldnt save print output in csv

I have this for loop:

for element in acl
....
if this
   do this {status_1}
elif that
   do that {status_2}
print({status})

But I'm having troubles to save that print in a csv files using the default csv module like this:

with open('op2.csv', 'w', newline='') as r:
    writer = csv.writer(r)
    writer.writerow(['a'])  # output header row as first line
    for loop describe above:
        writer.writerow([r'{status}'])


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source