I want to update my basic jumble game. I already did that the script gets words from a text file, now I want to separate them into modules as I have different text files wit
The problem you've stated is a standard namespace/scope problem. You've created a variable within the scope of amazement.py, but not in the jumble_game.py namespace. As a result, you can't access the top level variable in amazement.py without telling your program from where to get that variable.
You can do a few things. I'll list two:
1.
from amazement import filename
This will allow you to use the term "filename" as you've described.
or 2.
Replace any reference to filename
with amazement.filename
.
You can read more about scopes and namespace here: http://sebastianraschka.com/Articles/2014_python_scope_and_namespaces.html