Reputation: 305
I've been using pycharm for a little while and all working fine, then this morning I started it up and went to run some python code and got the message AttributeError: 'module' object has no attribute 'randrange'
I ran the code in another IDE (spyder) and it works fine,I haven't changed any settings in pycharm that I know of, anyone have any ideas what could be causing this issue?
my code:
def fac(num,yi):
import random
x = [[0,0]]
if num > 0.1:
x.append([num,yi])
x.extend(fac(num/2,yi+0.1*random.randrange(-10,10,1)))
return(x)
print(fac(10, 0))
Upvotes: 1
Views: 4608
Reputation: 83
I just had this problem, and confirmed that the code was correct by running it in IDLE. Restarting PyCharm fixed it for me; it now runs fine.
Upvotes: 1