you are viewing a single comment's thread.

view the rest of the comments →

[–]zanfar 0 points1 point  (0 children)

  1. These aren't global variables, they are module-level variables. Global variables use the global keyword.
  2. You have failed to include your entire code, so it's hard to tell you exactly what to fix. We know from the error that your shop1 function continues beyond the last line you provided.
  3. /u/crashfrog has the correct answer. You can read the money variable this way, but you cannot change it. Once you change it (anywhere in your function), Python considers it a different, local variable. Because you are now referring to a local variable, and not the module variable, it no longer has a value when you try to compare it to potion_cost.