I am writing the csv file in python and there are four levels of nested objects. like
I need to show the csv like this
StudentName, StudentCla
StudentName
StudentCla
You should Initialize s.subjects and subject.books with empty lists. That way you won't get an error when trying to iterate them here or on other places in your code.
s.subjects
subject.books