I have this code which generates a random number. I want it to save the random number on a new line/row every time it is run(the code).
I tried adding newLine and newRow but it did not work.
import csv
import random
newFile = open("random.csv",'w',newline='')
newWriter = csv.writer(newFile, dialect='excel')
newRow = []
case_number = random.randint(0,1000000000)
print("Your problem has been stored. We have allocated a case number which will be sent off to a technician. Please take a note of your case number: ", str(case_number))
newRow.append(case_number)
newWriter.writerow(newRow)
newFile.close()
And how can I shorten this piece of code?
Any help will be appreciated.
Thank you!
'a'instead of'w'.