Mistaking Dictionary Syntax
Mistaking Dictionary Syntax. You saw earlier that you could get a
SyntaxError if you leave the comma off of a dictionary element. Another form of invalid syntax with Python dictionaries is use of the equals sign to separate keys and values, instead of the colon.
00:22 Once again, the error message is not very helpful. The repeated line and caret, however, are very helpful. They’re pointing right to the problem character. This type of issue is common if you confuse Python syntax with that of other programming languages.
You’ll also see this if you confuse the act of defining a dictionary with a
dict() call. To fix this, you could replace the equal sign with a colon, or you can switch to using
dict(), as seen here.
Become a Member to join the conversation.