guard let
]]
guard
**import** UIKit
**func** rollSeveralDice(numberOfDice: Int, diceSides: Int) {
**guard** numberOfDice > 0 **else** {
print(" Cannot calculate roll of \(numberOfDice) dice")
**return**
}
**var** total = 0
**var** roll: Int
**var** totalString = ""
total = Int.random(in: 1...diceSides)
totalString = "\(total)"
**if** numberOfDice > 1 {
**for** _ **in** 2...numberOfDice {
roll = Int.random(in: 1...diceSides)
total = total + roll
totalString = totalString + ", \(roll)"
}
print(totalString)
print("Total roll: \(total)")
}
}
rollSeveralDice(numberOfDice: 0, diceSides: 8)