understand this error:AttributeError: 'Turtle' object has no attribute 'Listen'. Any ideas?

0 votes

this is my code

import turtle
import random
from turtle import *

m = turtle.Turtle()
m.speed(0)
m.width(7)

def go_up():
    if head.direction != "down":
        head.direction = "up"

def go_down():
    if head.direction != "up":
        head.direction = "down"

def go_left():
    if head.direction != "right":
        head.direction = "left"

def go_right():
    if head.direction != "left":
        head.direction = "right"

def move():
    if head.direction == "up":
        y = head.ycor()
        head.sety(y + 20)

    if head.direction == "down":
        y = head.ycor()
        head.sety(y - 20)

    if head.direction == "left":
        x = head.xcor()
        head.setx(x - 20)

    if head.direction == "right":
        x = head.xcor()
        head.setx(x + 20)

m.Listen()
m.onkeypress(go_up, "w")
m.onkeypress(go_down, "s")
m.onkeypress(go_left, "a")
m.onkeypress(go_right, "d")
May 20 in Python by MOHAMMED
• 120 points

edited May 20 by Gitika 174 views

1 answer to this question.

0 votes

Hey, @Mohammed,

You are getting this error because you are trying to access an attribute or method that does not exist on the object.

Try to replace:

m.Listen()

With the following:

m.listen()

Since python is case sensitive, "Listen" and "listen" makes a difference. Hence the error. 

I hope this will omit your error.

answered May 20 by Gitika
• 29,690 points

Related Questions In Python

0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
987 views
+1 vote
1 answer

Python error "AttributeError: 'Turtle' object has no attribute 'Shape'"

Hey @Nagya, replace python.Shape("Square") with the following: python.shape("square") Python is case ...READ MORE

answered Jun 19, 2019 in Python by Faiza
5,598 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,540 points
3,069 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 963 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

answered Apr 6 in Python by Gitika
• 29,690 points
434 views
0 votes
1 answer