I am new to python, please help me resolve this.
My code looks like:
if div == 0 or div == 1 or div == 2:
print (' A ', 'sometext')
elif div == 5 or div == 6:
print (' B ', 'some')
elif div == 3 or div == 4:
print (' C ', 'text')
I want to insert data into csv instead of printing
like this:
A,B,C
sometext,some,text
xhbasj,bjascn,bashc
bhhashc,bashjc,bcsahbch
cvashcj,bcashc,bcasc
here A,B,C will be like keys.
I have tried many options but none of them working, please help me resolve this
I have tried this
with open('trashData.csv', 'w', newline='') as fp:
a = csv.writer(fp, delimiter=',')
if div == 0 or div == 1 or div == 2:
data = [['A'],['sometext']]
a.writerows(data)