Ask coding questions

← Back to all posts
How do I make a code for if the input isn't a number from 0-100 print "you are wrong"
joshuam6060 (0)

In 26-28 I did a wrong line of code to show what I'm trying to do even though I know it is wrong.

Commentshotnewtop
Coder100 (12531)

Try something like:

if !0..100.contains(z) {
  print("make it a number from 1-100")
}

Ranges are probably going to be easier to understand and use.

read more

Coder100 (12531)
if !0...100.contains(z) {
  print("make it a number from 1-100")
}

@joshuam6060

joshuam6060 (0)

@Coder100 no it still doesn't work

Coder100 (12531)

btw, Int(0, 100) initializes 0 base 100, which is not what you want I don't think

RYANTADIPARTHI (3349)

This is because you are listing out 0, 100, but you have to use something called radix() because this will get all those values in random.

pepelaugh (658)

@RYANTADIPARTHI You're thinking Java, Int.random(in:) would easily satisfy OP's needs.