I am new to python. I\'m trying to write this
if x not in d: d[x] = {} q = d[x]
in a more compact way using the ternary operator
The reason that else (d[x] = {}) is a syntax error is that in Python, assignment is a statement. But the conditional operator expects expressions, and while every expression can be a statement, not every statement is an expression.
else (d[x] = {})