Trying to write a code at the moment that basically tests to see if the letter that lies at r (so here (2,3)) is equal to a particular letter or string.
def test():
txt = "test.txt"
r = (2,3)
if txt[r[0]][r[1]] == 'l':
return (True)
elif txt[r[0]][c[1]] == "m":
return (False)
elif txt[r[0]][c[1]] == "b":
return (True)
But i keep getting an error. The error dialogue is this:
if txt[r[0]][r[1]] == 'l':
IndexError: string index out of range
I have no idea what im doing wrong considering i had it working earlier today.
Also, before you ask, i have to code it this way for a particular reason.
Thanks.
Please note,
should be written as
and similarly other usage should be changed