Python returning non-sensical errors

  Kiến thức lập trình

Python seems to be returning errors that do not seem to make sense. might not be advanced enough to understand what’s going on, but it seems as if this is experiencing some major issue. I cannot tell what it is however, because the errors do not make any sense. Here’s the code snippet (line 18 starts at player equipped):

playerEquipped = {
    "weapon" ; "starter sword";
    "charm" : "no";
}

Specifically, it was returning errors about the code not having the curly brace being closed, and that it requires an expression, even though most tutorials on dictionaries never show anything related to expressions being called after said dictionary. You can see an image of the error here!

Originally, this dictionary was supposed to hold more information and make everything easier, but I find it causing more stress than managing 20 variables 🙁

This is just wrong syntax. You shouldn’t be using any semicolons (;) here; use colons (:) to separate a key from its value, and commas (,) to separate key/value pairs.

playerEquipped = {
    "weapon" : "starter sword",
    "charm" : "no",  #  this final comma is optional and usually omitted
}

LEAVE A COMMENT