Python Forum
Python-Can I get some help with this ModuleError
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-Can I get some help with this ModuleError
#4
You use k as a module name and you use it as an integer.

As a module name
import k as k  # Should be import k, not import k as k
And 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.
AlexPython likes this post
Reply


Messages In This Thread
RE: Python-Can I get some help with this ModuleError - by deanhystad - Sep-23-2022, 07:23 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020