Ask coding questions

← Back to all posts
NameError on a variable since is not defined
SHENGZHAO (0)

In my code, python is giving a NameError, that "A", "B" and "C" is not defined, even though on rows 10-15, I've made it so that "if row is something" then set it to whatever "something is" like if row == "A": row_index = A.
It seems like I made a mistake somewhere, but I can't find where. Can someone see what mistake I made?

Commentshotnewtop
a5rocks (774)

Right now you have [1:2]\ which isn't actually a thing. Python sees \ and then expects the next line to be a continuation of the current line.

Also, do you maybe mean row_index = "A" (as in a string "A"?).

SHENGZHAO (0)

@a5rocks
The \ must have been a typo there, but ahhh, that fixes the issue. Thanks!