I want to overwrite the file name student_information.txt. I have tried :
attribute_name = ["student_id", "name", "department", "sex", "age", "nationality", "grade"]
attribute_type = ["INT", "CHAR(20)", "CHAR(50)", "CHAR(1)", "INT", "CHAR(3)", "FLOAT"]
student_list = [("student_id", "name", "department", "sex", "age", "nationality", "grade"), ("student_id", "name", "department", "sex", "age", "nationality", "grade")]
f = open("student_information.txt", "w")
f.write('\n'.join('%s %s %s %s %s %s %s' % x for x in attribute_name))
f.write('\n'.join('%s %s %s %s %s %s %s' % x for x in attribute_type))
for i in range(len(student_list)):
f.write('\n'.join('%s %s %s %s %s %s %s' % x for x in student_list[i]))
f.close()
It gives error saying :
TypeError: not enough arguments for format string.
Anyone have any ideas why it's not working? Thanks.