Search code examples
pythonrandompycharmattributeerror

when i have multiple python files in pycharm it gives errors


i've been going through some tutorials and have been actively taking notes whilst watching the videos and copying the code. Which has resulted in having multiple python files in my pycharm projects.

I have noticed that when i reach a certain number of files the terminal returns back errors but when the code is run a new project folder it runs perfectly fine.

Not sure why that is, has anyone got any ideas? Also should i be creating multiple python files when learning?

This is an example of an error:

Code:

import random

value = random.randint(1, 6)
print(value)

error:

AttributeError: module 'random' has no attribute 'randint'

But when run in a new project it works...


Solution

  • Do you have another script called random? It might be trying to import .randint() from there.