Search code examples
pythonpython-3.ximporterror

AttributeError: module 'test' has no attribute 'randhiletter'


I am getting the error, in the title, even though there is a function randhiletter in the python file test.py. I am using this code in the file accessing test.py:

import test
print(test.randhiletter())

The code in test.py basically uses randint to assign a variable a number. Based on that number it will return a letter. There are two functions in test.py. These are randhiletter and randlowletter which do the same thing but for lowercase and uppercase letters. I do not understand why I am getting the error.


Solution

  • Credits to user2357112 supports Monica for this answer. He/she did not post one so I felt that I should to close the discussion or something: The issue was that I could not use the name test for the file I was trying to import as that is apparently already a python library.