user595985
user595985

Reputation: 1583

Creating a Class with variable properties

Hi I am interested in creating a class somewhat like this

- Class Tutor

My main issues is with the subjects, a tutor may have 1 to 10 primary subjects and similarly 1 to 10 secondary subjects, not all tutors will have have the same number of primary and secondary subjects so the class I am trying to create needs to be flexible enough to accommodate any number of primary & secondary subject combinations. How best to create a data structure that I can use like this

Upvotes: 0

Views: 54

Answers (1)

valentinas
valentinas

Reputation: 4337

Use a List, or tuple if you want several data types in the list.

class Tutor:
    firstName = ""
    lastName = ""
    age = 0
    primarySubjects = []
    secondarySubjects = []

Upvotes: 1

Related Questions