Im trying to write a function that writes multiple lists to a singular csv file and i am able to get the column titles to write, but not any of the data. My data is in lists that are similar to this [92,3801,2,22,4] and the second is [3.0,2,23,5] and im looking for guidance on this. Thank you!
import csv
def export_results(number_of_words_sentence,mean_word_per_sentence):
with open("assignment_7_results.csv", "w", newline="") as Assignment_7_results:
writer = csv.writer(Assignment_7_results)
writer.writerow(["Number of Words", "Words/Sentence"])
# Our .csv file will have two columns, one for the dict keys and one for the dict values
writer.writerows(number_of_words_sentence)
writer.writerows(mean_words_per_sentence)
writerowswrites rows, not columns. You'll have to zip and iterate over each pair of elements in turn, and callwriterow