Different solution and different bug

So solved this part a little bit differently, than in given example but also got a bug. Which I managed to solve on my own.

So the problem was that for some reason when I entered string that was shorter than the given word, let’s say 3 chars, it would still try to acces to 4th and 5th chars in it, because the given word was longer and it tried to go through to the end of it (I’m sorry if the explantation is a bit messy, english isn’t my first language, but I hope that anyone who reads this gets the idea). And it ment that the programm crushed, because it was trying to access sth that wasn’t there.

But yeah, as I said managed to solve it. The code I ended up with is in the image. Hope somone finds this helpfull or interesting :wink:

1 Like

I was having an issue with the debugging portion of this lecture and I kept getting an error every time I tried to input just one letter. I have noticed some differences in the way my VS is working compared to that of the instructors, so I tried rewriting the code as you have it above, fixed my issue. Makes me wonder why it happened though. Thanks for the post!

-Keith C.

Privacy & Terms