The OP asked for "You guessed correctly on your 2nd attempt". In other words, ordinal numbers. You code gives cardinal numbers, so not a correct solution.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.