I want the code to print the name of the variable and not the value. It just does not want to work.
I have not tried much as I have no idea how to do this. I also cannot find much documentation on this online.
import UIKit
var a = 1
var b = 2
var c = 3
var d = 4
var e = 1
var f = 2
var g = 3
var h = 4
var i = 1
var j = 2
var k = 3
var l = 4
var suggestedGroup1 = 16
var classStudents = [a,b,c,d,e,f,g,h,i,j,k,l]
var groupsNumber = 3
var peoplePerGroup = classStudents.count / groupsNumber
var totalClassPoints = a + b + c + d + e + f + g + h + i + j + k + l
var OnePerson = classStudents.randomElement()
var TwoPerson = classStudents.randomElement()
var ThreePerson = classStudents.randomElement()
var FourPerson = classStudents.randomElement()
suggestedGroup1 = OnePerson! + TwoPerson! + ThreePerson! + FourPerson!
while suggestedGroup1 != 10 {
OnePerson = classStudents.randomElement()
TwoPerson = classStudents.randomElement()
ThreePerson = classStudents.randomElement()
FourPerson = classStudents.randomElement()
suggestedGroup1 = OnePerson! + TwoPerson! + ThreePerson! + FourPerson!
}
if suggestedGroup1 == 10 {
print ("Group 1 is made up of", OnePerson!, ",", TwoPerson!, ",", ThreePerson!, "and", FourPerson!)
}
When it prints ("Group 1 is made up of", OnePerson!, ",", TwoPerson!, ",", ThreePerson!, "and", FourPerson!), I want the name of the person and not their "value".