I am writing a command-line program for a dice game, and now I want to randomly shake the dice twice and check if their sum is even or odd. However, in the if statement if diceSum % 2 == 0 I keep getting the fault "Expected '{' after 'if' condition". As far as I am concerned, my syntax seems fine. Does anyone have any suggestions?
var diceSUM:Int = 0
var diceEO = ""
for _ in 1...2 {
let diceShake = Int.random(in: 1...6)
diceSUM = diceSUM + diceShake
}
if diceSUM % 2 == 0 {
diceEO = "Cho"
} else {
diceEO = "Han"
}
print(diceSUM)
Aucun commentaire:
Enregistrer un commentaire