Sep-23-2022, 07:23 AM
(This post was last modified: Sep-23-2022, 07:23 AM by deanhystad.)
You use k as a module name and you use it as an integer.
As a module name
Your program works fine if you delete the "import k as k" line.
As a module name
import k as k # Should be import k, not import k as kAnd here as an integer
k = random.randint(1,50) #Now k is an int. Module k is gone!My guess is you do not have a module named k that you want to import. I think you believe "import k as k" is defining a global variable named "k". You never treat k like a module. There is no x = k.function(args) or y = y + k.value type references to the module "k" in your program. And as soon as you assign k an integer value, you have no way to reference the module anymore.
Your program works fine if you delete the "import k as k" line.