I’m currently taking a cource project Swift Sets School Roster
In paragrath #6 Class size, you need to print information about the number of classes that have 7 or more students.
var spanish101: Set = ["Angela", "Declan", "Aldany", "Alex", "Sonny", "Alif", "Skyla"]
var german101: Set = ["Angela", "Alex", "Declan", "Kenny", "Cynara", "Adam"]
var advancedCalculus: Set = ["Cynara", "Gabby", "Angela", "Samantha", "Ana", "Aldany", "Galina", "Jasmine"]
var artHistory: Set = ["Samantha", "Vanessa", "Aldrian", "Cynara", "Kenny", "Declan", "Skyla"]
var englishLiterature: Set = ["Gabby", "Jasmine", "Alex", "Alif", "Aldrian", "Adam", "Angela"]
var computerScience: Set = ["Galina", "Kenny", "Sonny", "Alex", "Skyla"]
var classes: Set = [spanish101, german101, advancedCalculus, artHistory, englishLiterature, computerScience]
var sevenPlus = 0
for aClass in classes {
if aClass.count >= 7 {
sevenPlus += 1
}
}
print(sevenPlus)
// Prints: 4
But I’m want to print code with Set names like this
// Prints: Сlasses with more than 7 students:
// Prints: spanish101, advancedCalculus, artHistory, englishLiterature
// Prints: Total classes: 4
Meaning so that not just the number, but also the name of the class in which there are more than seven students