#Index error

1 messages · Page 1 of 1 (latest)

red cairnBOT
#

<@&987246399047479336> please have a look, thanks.

red cairnBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

spark storm
#

My code.

marsh pawn
#

write out your math, u will notice

spark storm
wicked wharf
#

index 3 out of bounds for length 3 is your error message

#

Since your loop starts from 0, i should be {0,1,2} for a string that has 3 characters

#

so when we get to the last loop i.e. i is 2

#

You're doing i+1 which becomes 3 and your substring fails with an exception

#

A simple way to do palindrome would be to have 2 variables:

originalString reversedString

And then loop over each character in originalString and match it with reversedString once you get 2 matches, stop looping and return true