Consider the following code:
class Student :
def __init__(self, fn, sn, language):
self.fn = fn
self.sn = sn
self.language = language
def __str__(self):
if self.language == 'Chinese':
return self.sn+ self.fn
else:
return self.fn + ' ' + self.sn
def initGroup():
g = []
for s in [ Student('東坡', '蘇', 'Chinese'),
Student('宗元', '柳', 'Chinese'),
Student('Sandra', "Bullock", "English"),
Student('Julia', 'Roberts', "English") ]:
g.append(s)
return g
def main():
group = initGroup()
for s in group:
print(s)
main()