Expression: String subscript out of range

If I get the Bull correct which my Hidden word is “copywrites” then this game works. If I get it wrong; for example by using the word “create”, then I get the below error:

Expression: String subscript out of range

Line 49 is where the problem is, but it is correct.

I do not see why my program shuts down instead of show me any of the Cows.

Did you not see this annotation in the previous lecture?

I vaguely recall him saying something like that but it seemed like when Ben ran his game he did not get these errors. I thought I may have done something wrong.

That’s because the bug is related to the lengths. If Guess is shorter than the HiddenWord then you’ll go out of range.

Oh okay. Thanks!

Privacy & Terms