error cannot assign value of type int to string swift - what am I doing wrong?
print("guess a number that I thought of")
let number = Int.random(in: 0...100)
var z = readLine()
if z = number{
print("yay")
}
Voters
Ask coding questions
print("guess a number that I thought of")
let number = Int.random(in: 0...100)
var z = readLine()
if z = number{
print("yay")
}
Right here, you forgot an
=
. Remember.=
is for assignment and==
is for equality:@Coder100
I tried that and it didn't work.
z has to be of type string @joshuam6060
@joshuam6060
still isn't working @Coder100
oh right,
z
can be optional.@joshuam6060
thanks you so much @Coder100
np :) @joshuam6060