class is a Python keyword. It means that this word has a particular meaning for the Python language, and thus cannot be used as a variable name.
Here is the list of keywords, as given by the keyword module:
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
You can also get it directly from the documentation.
You should also note that there is another set of words called builtins (full set here) for which it is bad practice to use as variable names, although you won't get a SyntaxError.
A common way to go around this is either to use klass instead of class, or add a suffix to the keyword, like in class_ = 8. Or you can also find a better naming, depending on the purpose of your variable: class_number = 8.