Why this code doesn't work? | Sololearn: Learn to code for FREE!

+1

Why this code doesn't work?

When i do this lesson Sololearn shows an error But when i test this code in XCode playground, it works correctly let siblings = 3 let popsicles = 9 if (popsicles % siblings) == 0 { print("give away") } else { print("eat them yourself") }

4/9/2021 4:51:39 PM

Игорь Щербак

3 Answers

New Answer

+2

You should get the variables from inputs.

+2

let siblings = Int(readLine(strippingNewline: true)!)! let popsicles = Int(readLine(strippingNewline: true)!)! if (popsicles % siblings == 0) { print("give away") } else { print("eat them yourself") }

+1

please can you explain in more detail? I don't understand, why here it doesn't work