No, it should be < the target ( not equal to it).
When mining Bitcoin , the goal is to find a hash that is not equal to the target(near impossible), but less than the target value(probalistic). The target is a 256-bit number that the network adjusts every 2016 blocks to ensure that the time between blocks remains approximately 10 minutes on average. A lower target means a higher difficulty in finding a valid block.
The hashing process is essentially a race to find a nonce value that, when combined with the block's header data(which itself contains the Merkle root of the previous blocks tx) and passed through the SHA-256 hashing algorithm twice, produces a hash value that is less than the network-defined target.
Therefore the condition, in the educational example, if hash < target: is correct because you are looking for a hash that is numerically less than the target.