In python AttributeError: module ‘random’ has no attribute ‘ranint’. Did you mean: ‘randint’? we face this error message when we incorrectly type ‘randint’ with a random module then the python interpreter shows this error message, This is a normal spelling mistake If you want to fix this error you need to just use random.randint with correct spelling, For more clarification, see the below example.
Wrong Code
import turtle
import random
t = turtle.Turtle()
#t.colormode(255)
def random_color():
r = random.ranint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
random_color = (r, g, b)
return random_color
Error Massage
File "/home/kali/python/webproject/turtle/random_walk/main.py", line 19, in <module>
t.color(random_color())
File "/home/kali/python/webproject/turtle/random_walk/main.py", line 7, in random_color
r = random.ranint(0, 255)
AttributeError: module 'random' has no attribute 'ranint'. Did you mean: 'randint'?
Wrong code line
r = random.ranint(0, 255)
Correct code line
r = random.randint(0, 255)
- Improper action: ‘ranint’ (wroung spelling).
- Correct action: randint (correct spelling).
Entire Correct Code line
import turtle
import random
t = turtle.Turtle()
#t.colormode(255)
def random_color():
r = random.randint(0, 255)
g = random.randint(0, 255)
b = random.randint(0, 255)
random_color = (r, g, b)
return random_color
What is AttributeError: module ‘random’ has no attribute ‘ranint’. Did you mean: ‘randint’?
In python, we face this error message when we incorrectly type ‘randint’ with a random module then the python interpreter shows this error message.
How to fix TypeError: TNavigator.forward() missing 1 required positional argument: ‘distance’?
If you want to fix this error you need to just use random.randint with correct spelling, For more clarification, see the above example.
Another article for you: Most dangerous error in python.
- typeerror: ‘<‘ not supported between instances of ‘str’ and ‘int’.
- positional argument follows keyword argument.
For more information Visit YouTube Channel.

