I am trying to use random library in Python. The code is as follows:
import random
#print random integer
rand_int = random.randint(1,10)
print(rand_int)
However VSCode is showing the error:
devjyotisinha@Devjyotis-MacBook-Air Udemy % python3 -u "/Users/devjyotisinha/Desktop/Python/Udemy/random.py"
Traceback (most recent call last):
File "/Users/devjyotisinha/Desktop/Python/Udemy/random.py", line 1, in <module>
import random
File "/Users/devjyotisinha/Desktop/Python/Udemy/random.py", line 3, in <module>
rand_int = random.randint(1,10)
AttributeError: partially initialized module 'random' has no attribute 'randint' (most likely due to a circular import)
The code is working fine on online editors such as replit.com but VSCode is showing an error. What does the attribute error mean as I learnt that randint is an attribute of random?